Linux Device Drivers (3rd Edition) [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Linux Device Drivers (3rd Edition) [Electronic resources] - نسخه متنی

Jonathan Corbet, Greg Kroah-Hartman, Alessandro Rubini

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید








17.16. 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>


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


struct net_device *alloc_netdev(int sizeof_priv, char *name, void

(*setup)(struct net_device *);

struct net_device *alloc_etherdev(int sizeof_priv);

void free_netdev(struct net_device *dev);


Functions for allocating and freeing net_device
structures.


int register_netdev(struct net_device *dev);

void unregister_netdev(struct net_device *dev);


Registers and unregisters a network device.


void *netdev_priv(struct net_device *dev);


A function that retrieves the pointer to the driver-private area of a
network device structure.


struct net_device_stats;


A structure that holds device statistics.


netif_start_queue(struct net_device *dev);

netif_stop_queue(struct net_device *dev);

netif_wake_queue(struct net_device *dev);


Functions that control the passing of packets to the driver for
transmission. No packets are 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.


skb_shinfo(struct sk_buff *skb);


A macro that provides access to the "shared
info" portion of a packet buffer.


void netif_rx(struct sk_buff *skb);


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


void netif_rx_schedule(dev);


Function that informs the kernel that packets are available and that
polling should be started on the interface; it is used only by
NAPI-compliant drivers.


int netif_receive_skb(struct sk_buff *skb);

void netif_rx_complete(struct net_device *dev);


Functions that should be used only by NAPI-compliant drivers.
netif_receive_skb is the NAPI equivalent to
netif_rx; it feeds a packet into the kernel.
When a NAPI-compliant driver has exhausted the supply of received
packets, it should reenable interrupts, and call
netif_rx_complete to stop polling.


#include <linux/if.h>


Included by netdevice.h, this file declares the
interface flags (IFF_ macros) and struct
ifmap
, which has a major role in the
ioctl implementation for network drivers.


void netif_carrier_off(struct net_device *dev);

void netif_carrier_on(struct net_device *dev);

int netif_carrier_ok(struct net_device *dev);


The first two functions may be used to tell the kernel whether a
carrier signal is currently present on the given interface.
netif_carrier_ok tests the carrier state as
reflected in the device structure.


#include <linux/if_ether.h>

ETH_ALEN

ETH_P_IP

struct ethhdr;


Included by netdevice.h,
if_ether.h defines all the
ETH_ macros used to represent octet lengths (such
as the address length) and network protocols (such as IP). It also
defines the ethhdr structure.


#include <linux/skbuff.h>


The definition of struct sk_buff and related
structures, as well as several inline functions to act on the
buffers. This header is included by netdevice.h.


struct sk_buff *alloc_skb(unsigned int len, int priority);

struct sk_buff *dev_alloc_skb(unsigned int len);

void kfree_skb(struct sk_buff *skb);

void dev_kfree_skb(struct sk_buff *skb);

void dev_kfree_skb_irq(struct sk_buff *skb);

void dev_kfree_skb_any(struct sk_buff *skb);


Functions that handle the allocation and freeing of socket buffers.
Drivers should normally use the dev_ variants,
which are intended for that purpose.


unsigned char *skb_put(struct sk_buff *skb, int len);

unsigned char *_ _skb_put(struct sk_buff *skb, int len);

unsigned char *skb_push(struct sk_buff *skb, int len);

unsigned char *_ _skb_push(struct sk_buff *skb, int len);


Functions that add data to an skb;
skb_put puts the data at the end of the
skb, while skb_push puts it
at the beginning. The regular versions perform checking to ensure
that adequate space is available; double-underscore versions leave
those tests out.


int skb_headroom(struct sk_buff *skb);

int skb_tailroom(struct sk_buff *skb);

void skb_reserve(struct sk_buff *skb, int len);


Functions that perform management of space within an
skb. skb_headroom and
skb_tailroom tell how much space is available at
the beginning and end, respectively, of an skb.
skb_reserve may be used to reserve space at the
beginning of an skb, which must be empty.


unsigned char *skb_pull(struct sk_buff *skb, int len);


skb_pull
"removes" data from an
skb by adjusting the internal pointers.


int skb_is_nonlinear(struct sk_buff *skb);


Function that returns a true value if this skb is separated into
multiple fragments for scatter/gather I/O.


int skb_headlen(struct sk_buff *skb);


Returns the length of the first segment of the skbthat part
pointed to by skb->data.


void *kmap_skb_frag(skb_frag_t *frag);

void kunmap_skb_frag(void *vaddr);


Functions that provide direct access to fragments within a nonlinear
skb.


#include <linux/etherdevice.h>

void ether_setup(struct net_device *dev);


Function that sets most device methods to the general-purpose
implementation for Ethernet drivers. It also sets
dev->flags and assigns the next available
ethx name to dev->name if
the first character in the name is a blank space or the
NULL character.


unsigned short eth_type_trans(struct sk_buff *skb, struct net_device *dev);


When an Ethernet interface receives a packet, this function can be
called to set skb->pkt_type. The return value
is a protocol number that is usually stored in
skb->protocol.


#include <linux/sockios.h>

SIOCDEVPRIVATE


The first of 16 ioctl commands that can be
implemented by each driver for its own private use. All the network
ioctl commands are defined in
sockios.h.


#include <linux/mii.h>

struct mii_if_info;


Declarations and a structure supporting drivers of devices that
implement the MII standard.


#include <linux/ethtool.h>

struct ethtool_ops;


Declarations and structures that let devices work with the
ethtool utility.




    / 202