SlideShare une entreprise Scribd logo
1  sur  15
© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Network Drivers
2© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What to Expect?
Understanding Network Subsystem
Network Drivers: A different category
Writing Network Drivers
3© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Network Subsystem
(Network) Protocol Stack
Typically, the TCP/IP Stack
Interfaces with the User Space through network interfaces, instead
of device files
Unlike other drivers, does not provide any /sys or /dev entries
Interface Examples: eth0, wlan1, …
Resides in the <kernel_source>/net folder
Network Interface Card (NIC) Drivers
Driver for the Physical Network Cards
Provides uniform hardware independent interface for the network
protocol layer to access the card
Typically, resides in the <kernel_source>/drivers/net folder
4© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Related Data Structures
Writing a NIC or Network Driver involves
Interacting with the underlying Card over its I/O Bus
Providing the standard APIs to the Protocol Stack
This needs three kind of Data Structures
Core of Protocol Stack
struct sk_buff
NIC & Protocol Stack Interface
struct net_device
NIC I/O bus, e.g. PCI, USB, …
I/O bus specific data structure
5© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
struct sk_buff
Network Packet Descriptor
Header: <linux/skbuff.h>
Driver relevant Fields
head – points to the start of the packet
tail – points to the end of the packet
data – points to the start of the pkt payload
end – points to the end of the packet payload
len – amount of data that the packet contains
6© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Socket Buffer APIs
Header: <linux/skbuff.h>
SK Buffer Storage
struct sk_buff *dev_alloc_skb(len);
dev_kfree_skb(skb);
SK Buffer Operations
void skb_reserve(struct sk_buff *, int len);
struct sk_buff *skb_clone(struct sk_buff *, gfp_t);
unsigned char *skb_put(struct sk_buff *, int len);
7© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
The Big Picture
(with a PCI NIC)
Network
Stack
sk_buff
net_device
eth0
system calls
ifconfig ping tcpdump ...
PCI Driver
handler
Tx
dpv
Network
Vertical
PCI
Horizontal
NIC Driver
PCI Core
PCI Ctrl Drv
PCI Host Ctrl
DMA
Ctrl
System RAM
Tx
Buf
Rx
Buf
PHY
NIC
PCI
Cfg
Space
Reg
Space
sk_buff...
CPU
User
Space
Kernel
Space
Hardware
Space
poll
Soft IRQ
TxDesc
RxDesc
8© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
struct net_device
Header: <linux/netdevice.h>
Driver relevant Operation Fields
Activation: open, stop, ioctl
Data Transfer: start_xmit, poll (NAPI: new API)
WatchDog: tx_timeout, int watchdog_timeo
Statistics: get_stats, get_wireless_stats
Typically uses struct net_device_stats, populated earlier
Configuration: struct *ethtool_ops, change_mtu
Structure defined in Header: <linux/ethtool.h>
Bus Specific: mem_start, mem_end
Latest kernels have all the operations moved under
struct net_dev_ops
And typically, a prefix ndo_ added and some name changes
9© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Net Device Registration
Header: <linux/netdevice.h>
Net Device Storage
struct net_device *alloc_etherdev(sizeof_priv);
struct net_device *alloc_ieee80211dev(sizeof_priv);
struct net_device *alloc_irdadev(sizeof_priv);
struct net_device *alloc_netdev(sizeof_priv, name, setup_fn);
void free_netdev(struct net_device *);
Registering the Net Device
int register_netdev(struct net_device *);
void unregister_netdev(struct net_device *);
10© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Network Device Open & Close
A typical Network Device Open
Allocates ring buffers and associated sk_buffs
Initializes the Device
Gets the MAC, … from device EEPROM
Requests firmware download, if needed
int request_firmware(fw, name, device);
Register the interrupt handler(s)
A typical Network Device Close
Would do the reverse in chronology reverse order
11© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Packet Receive Interrupt Handler
A typical receive interrupt handler
Minimally handles the packet received
Sanity checks
Puts back equal number of sk_buffs for re-use
Passes the associated sk_buffs (& ring buffers) to the
protocol layer by the NET_RX_SOFTIRQ
On higher load, switch to poll mode, if supported,
which then passes the associated sk_buffs (& ring
buffers) to the protocol layer by the
NET_RX_SOFTIRQ
12© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Flow Control related APIs
For interaction with the protocol layer
Header: <linux/netdevice.h>
APIs
void netif_start_queue(struct net_device *);
void netif_stop_queue(struct net_device *);
void netif_wake_queue(struct net_device *);
int netif_queue_stopped(struct net_device *);
13© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Network Driver Examples
Driver: snull
Browse & Discuss
Driver for Realtek NIC 8136
Browse & Hack
14© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What all have we learnt?
Linux Network Subsystem
How are Network Drivers different?
Writing Network Drivers
Key Data Structures & their APIs
sk_buff & net_device
Network Device Registration
Network Device Operations
Interrupt Handling for Packets received
Flow Control related APIs
15© 2010-16 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Any Queries?

Contenu connexe

Tendances (20)

Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
 
Bootloaders
BootloadersBootloaders
Bootloaders
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 
Linux dma engine
Linux dma engineLinux dma engine
Linux dma engine
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Analysis of Open-Source Drivers for IEEE 802.11 WLANs
Analysis of Open-Source Drivers for IEEE 802.11 WLANsAnalysis of Open-Source Drivers for IEEE 802.11 WLANs
Analysis of Open-Source Drivers for IEEE 802.11 WLANs
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
 
U boot-boot-flow
U boot-boot-flowU boot-boot-flow
U boot-boot-flow
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
 
I2C Subsystem In Linux-2.6.24
I2C Subsystem In Linux-2.6.24I2C Subsystem In Linux-2.6.24
I2C Subsystem In Linux-2.6.24
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Linux Network Stack
Linux Network StackLinux Network Stack
Linux Network Stack
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
 

En vedette (20)

File System Modules
File System ModulesFile System Modules
File System Modules
 
Introduction to Linux Drivers
Introduction to Linux DriversIntroduction to Linux Drivers
Introduction to Linux Drivers
 
Serial Drivers
Serial DriversSerial Drivers
Serial Drivers
 
Interrupts
InterruptsInterrupts
Interrupts
 
Block Drivers
Block DriversBlock Drivers
Block Drivers
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
PCI Drivers
PCI DriversPCI Drivers
PCI Drivers
 
I2C Drivers
I2C DriversI2C Drivers
I2C Drivers
 
USB Drivers
USB DriversUSB Drivers
USB Drivers
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Embedded C
Embedded CEmbedded C
Embedded C
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
 
References
ReferencesReferences
References
 
Platform Drivers
Platform DriversPlatform Drivers
Platform Drivers
 
Character Drivers
Character DriversCharacter Drivers
Character Drivers
 
Video Drivers
Video DriversVideo Drivers
Video Drivers
 
Low-level Accesses
Low-level AccessesLow-level Accesses
Low-level Accesses
 
Kernel Programming
Kernel ProgrammingKernel Programming
Kernel Programming
 
BeagleBoard-xM Bootloaders
BeagleBoard-xM BootloadersBeagleBoard-xM Bootloaders
BeagleBoard-xM Bootloaders
 
File Systems
File SystemsFile Systems
File Systems
 

Similaire à Network Drivers

Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -evechiportal
 
Better Network Management Through Network Programmability
Better Network Management Through Network ProgrammabilityBetter Network Management Through Network Programmability
Better Network Management Through Network ProgrammabilityCisco Canada
 
Advanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkAdvanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkRiyaj Shamsudeen
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rulesFreddy Buenaño
 
Code Red Security
Code Red SecurityCode Red Security
Code Red SecurityAmr Ali
 
[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practicalMoabi.com
 
DPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingDPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingMichelle Holley
 
05 module managing your network enviornment
05  module managing your network enviornment05  module managing your network enviornment
05 module managing your network enviornmentAsif
 
Cisco Live! :: Introduction to IOS XR for Enterprises and Service Providers
Cisco Live! :: Introduction to IOS XR for Enterprises and Service ProvidersCisco Live! :: Introduction to IOS XR for Enterprises and Service Providers
Cisco Live! :: Introduction to IOS XR for Enterprises and Service ProvidersBruno Teixeira
 
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...PROIDEA
 
Q2.12: Power Management Across OSs
Q2.12: Power Management Across OSsQ2.12: Power Management Across OSs
Q2.12: Power Management Across OSsLinaro
 
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SPKrzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SPPROIDEA
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)ijceronline
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Andriy Berestovskyy
 

Similaire à Network Drivers (20)

Ccna Imp Guide
Ccna Imp GuideCcna Imp Guide
Ccna Imp Guide
 
Linux Network Management
Linux Network ManagementLinux Network Management
Linux Network Management
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
 
Better Network Management Through Network Programmability
Better Network Management Through Network ProgrammabilityBetter Network Management Through Network Programmability
Better Network Management Through Network Programmability
 
Advanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkAdvanced RAC troubleshooting: Network
Advanced RAC troubleshooting: Network
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rules
 
Code Red Security
Code Red SecurityCode Red Security
Code Red Security
 
[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical
 
DPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingDPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet Processing
 
05 module managing your network enviornment
05  module managing your network enviornment05  module managing your network enviornment
05 module managing your network enviornment
 
Sockets and Socket-Buffer
Sockets and Socket-BufferSockets and Socket-Buffer
Sockets and Socket-Buffer
 
BeagleBone Black Booting Process
BeagleBone Black Booting ProcessBeagleBone Black Booting Process
BeagleBone Black Booting Process
 
Cisco Live! :: Introduction to IOS XR for Enterprises and Service Providers
Cisco Live! :: Introduction to IOS XR for Enterprises and Service ProvidersCisco Live! :: Introduction to IOS XR for Enterprises and Service Providers
Cisco Live! :: Introduction to IOS XR for Enterprises and Service Providers
 
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
 
Q2.12: Power Management Across OSs
Q2.12: Power Management Across OSsQ2.12: Power Management Across OSs
Q2.12: Power Management Across OSs
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SPKrzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
Krzysztof Mazepa - Netflow/cflow - ulubionym narzędziem operatorów SP
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
 
The Cell Processor
The Cell ProcessorThe Cell Processor
The Cell Processor
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
 

Plus de Anil Kumar Pugalia (20)

File System Modules
File System ModulesFile System Modules
File System Modules
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Processes
ProcessesProcesses
Processes
 
System Calls
System CallsSystem Calls
System Calls
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Embedded Software Design
Embedded Software DesignEmbedded Software Design
Embedded Software Design
 
Playing with R L C Circuits
Playing with R L C CircuitsPlaying with R L C Circuits
Playing with R L C Circuits
 
Mobile Hacking using Linux Drivers
Mobile Hacking using Linux DriversMobile Hacking using Linux Drivers
Mobile Hacking using Linux Drivers
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Functional Programming with LISP
Functional Programming with LISPFunctional Programming with LISP
Functional Programming with LISP
 
Power of vi
Power of viPower of vi
Power of vi
 
"make" system
"make" system"make" system
"make" system
 
Hardware Design for Software Hackers
Hardware Design for Software HackersHardware Design for Software Hackers
Hardware Design for Software Hackers
 
RPM Building
RPM BuildingRPM Building
RPM Building
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & Profiling
 
System Calls
System CallsSystem Calls
System Calls
 
Timers
TimersTimers
Timers
 
Threads
ThreadsThreads
Threads
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Processes
ProcessesProcesses
Processes
 

Dernier

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 

Dernier (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Network Drivers

  • 1. © 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Network Drivers
  • 2. 2© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What to Expect? Understanding Network Subsystem Network Drivers: A different category Writing Network Drivers
  • 3. 3© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Network Subsystem (Network) Protocol Stack Typically, the TCP/IP Stack Interfaces with the User Space through network interfaces, instead of device files Unlike other drivers, does not provide any /sys or /dev entries Interface Examples: eth0, wlan1, … Resides in the <kernel_source>/net folder Network Interface Card (NIC) Drivers Driver for the Physical Network Cards Provides uniform hardware independent interface for the network protocol layer to access the card Typically, resides in the <kernel_source>/drivers/net folder
  • 4. 4© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Related Data Structures Writing a NIC or Network Driver involves Interacting with the underlying Card over its I/O Bus Providing the standard APIs to the Protocol Stack This needs three kind of Data Structures Core of Protocol Stack struct sk_buff NIC & Protocol Stack Interface struct net_device NIC I/O bus, e.g. PCI, USB, … I/O bus specific data structure
  • 5. 5© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. struct sk_buff Network Packet Descriptor Header: <linux/skbuff.h> Driver relevant Fields head – points to the start of the packet tail – points to the end of the packet data – points to the start of the pkt payload end – points to the end of the packet payload len – amount of data that the packet contains
  • 6. 6© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Socket Buffer APIs Header: <linux/skbuff.h> SK Buffer Storage struct sk_buff *dev_alloc_skb(len); dev_kfree_skb(skb); SK Buffer Operations void skb_reserve(struct sk_buff *, int len); struct sk_buff *skb_clone(struct sk_buff *, gfp_t); unsigned char *skb_put(struct sk_buff *, int len);
  • 7. 7© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. The Big Picture (with a PCI NIC) Network Stack sk_buff net_device eth0 system calls ifconfig ping tcpdump ... PCI Driver handler Tx dpv Network Vertical PCI Horizontal NIC Driver PCI Core PCI Ctrl Drv PCI Host Ctrl DMA Ctrl System RAM Tx Buf Rx Buf PHY NIC PCI Cfg Space Reg Space sk_buff... CPU User Space Kernel Space Hardware Space poll Soft IRQ TxDesc RxDesc
  • 8. 8© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. struct net_device Header: <linux/netdevice.h> Driver relevant Operation Fields Activation: open, stop, ioctl Data Transfer: start_xmit, poll (NAPI: new API) WatchDog: tx_timeout, int watchdog_timeo Statistics: get_stats, get_wireless_stats Typically uses struct net_device_stats, populated earlier Configuration: struct *ethtool_ops, change_mtu Structure defined in Header: <linux/ethtool.h> Bus Specific: mem_start, mem_end Latest kernels have all the operations moved under struct net_dev_ops And typically, a prefix ndo_ added and some name changes
  • 9. 9© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Net Device Registration Header: <linux/netdevice.h> Net Device Storage struct net_device *alloc_etherdev(sizeof_priv); struct net_device *alloc_ieee80211dev(sizeof_priv); struct net_device *alloc_irdadev(sizeof_priv); struct net_device *alloc_netdev(sizeof_priv, name, setup_fn); void free_netdev(struct net_device *); Registering the Net Device int register_netdev(struct net_device *); void unregister_netdev(struct net_device *);
  • 10. 10© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Network Device Open & Close A typical Network Device Open Allocates ring buffers and associated sk_buffs Initializes the Device Gets the MAC, … from device EEPROM Requests firmware download, if needed int request_firmware(fw, name, device); Register the interrupt handler(s) A typical Network Device Close Would do the reverse in chronology reverse order
  • 11. 11© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Packet Receive Interrupt Handler A typical receive interrupt handler Minimally handles the packet received Sanity checks Puts back equal number of sk_buffs for re-use Passes the associated sk_buffs (& ring buffers) to the protocol layer by the NET_RX_SOFTIRQ On higher load, switch to poll mode, if supported, which then passes the associated sk_buffs (& ring buffers) to the protocol layer by the NET_RX_SOFTIRQ
  • 12. 12© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Flow Control related APIs For interaction with the protocol layer Header: <linux/netdevice.h> APIs void netif_start_queue(struct net_device *); void netif_stop_queue(struct net_device *); void netif_wake_queue(struct net_device *); int netif_queue_stopped(struct net_device *);
  • 13. 13© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Network Driver Examples Driver: snull Browse & Discuss Driver for Realtek NIC 8136 Browse & Hack
  • 14. 14© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. What all have we learnt? Linux Network Subsystem How are Network Drivers different? Writing Network Drivers Key Data Structures & their APIs sk_buff & net_device Network Device Registration Network Device Operations Interrupt Handling for Packets received Flow Control related APIs
  • 15. 15© 2010-16 SysPlay Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?