Skip to Content
Linux Device Drivers, Second Edition
book

Linux Device Drivers, Second Edition

by Jonathan Corbet, Alessandro Rubini
June 2001
Intermediate to advanced
592 pages
19h 20m
English
O'Reilly Media, Inc.
Content preview from Linux Device Drivers, Second Edition

Quick Reference

This section provides a reference for the concepts introduced in this chapter. It also explains the role of each header file that a driver needs to include. The lists of fields in the net_device and sk_buff structures, however, are not repeated here.

#include <linux/netdevice.h>

This header hosts the definitions of struct net_device and struct net_device_stats, and includes a few other headers that are needed by network drivers.

int register_netdev(struct net_device *dev); , void unregister_netdev(struct net_device *dev);

Register and unregister a network device.

SET_MODULE_OWNER(struct net_device *dev);

This macro will store a pointer to the current module in the device structure (or in any structure with an owner field, actually); it is used to enable the networking subsystem to manage the module’s use count.

netif_start_queue(struct net_device *dev); , netif_stop_queue(struct net_device *dev); , netif_wake_queue(struct net_device *dev);

These functions control the passing of packets to the driver for transmission. No packets will be transmitted until netif_start_queue has been called. netif_stop_queue suspends transmission, and netif_wake_queue restarts the queue and pokes the network layer to restart transmitting packets.

void netif_rx(struct sk_buff *skb);

This function can be called (including at interrupt time) to notify the kernel that a packet has been received and encapsulated into a socket buffer.

#include <linux/if.h>

Included ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 0596000081Supplemental ContentCatalog PageErrata