SlideShare a Scribd company logo
1 of 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?

More Related Content

What's hot (20)

PCI Drivers
PCI DriversPCI Drivers
PCI Drivers
 
Detailed iSCSI presentation
Detailed iSCSI presentationDetailed iSCSI presentation
Detailed iSCSI presentation
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
Spi drivers
Spi driversSpi drivers
Spi drivers
 
Block Drivers
Block DriversBlock Drivers
Block Drivers
 
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver
 
USB Drivers
USB DriversUSB Drivers
USB Drivers
 
Pcie drivers basics
Pcie drivers basicsPcie drivers basics
Pcie drivers basics
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking Explained
 
Linux MMAP & Ioremap introduction
Linux MMAP & Ioremap introductionLinux MMAP & Ioremap introduction
Linux MMAP & Ioremap introduction
 
Interrupts
InterruptsInterrupts
Interrupts
 
VLANs in the Linux Kernel
VLANs in the Linux KernelVLANs in the Linux Kernel
VLANs in the Linux Kernel
 
LinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking WalkthroughLinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking Walkthrough
 
Introduction to Linux Drivers
Introduction to Linux DriversIntroduction to Linux Drivers
Introduction to Linux Drivers
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
Fun with Network Interfaces
Fun with Network InterfacesFun with Network Interfaces
Fun with Network Interfaces
 
Iptables the Linux Firewall
Iptables the Linux Firewall Iptables the Linux Firewall
Iptables the Linux Firewall
 
I2C Drivers
I2C DriversI2C Drivers
I2C Drivers
 
Dpdk performance
Dpdk performanceDpdk performance
Dpdk performance
 

Viewers also liked (15)

File System Modules
File System ModulesFile System Modules
File System Modules
 
Serial Drivers
Serial DriversSerial Drivers
Serial 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
 
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
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
 
BeagleBoard-xM Bootloaders
BeagleBoard-xM BootloadersBeagleBoard-xM Bootloaders
BeagleBoard-xM Bootloaders
 
File Systems
File SystemsFile Systems
File Systems
 

Similar to 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
 

Similar to 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)
 

More from 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
 

Recently uploaded

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 

Recently uploaded (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 

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?