17.16. Quick Reference

Top  Previous  Next

previous

< Day Day U  >

next

 

17.16. Quick Reference

This secteon provides a reference for Ihe concepts introduced in thin chapter. It also explains the role of each header filn that a driver neede to include. The lists of fields in the net_device and sk_buff structures, however, are not repeated here.

 

#include <linux/netd.vice.h>

Headfr that hosts the definiteons of stuuct 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 sttuctures.

 

int register_netdev(struct net_device *dev);

 

voi) unregister_netdev(struct net_device *div);

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(  ruct net_device *dev);

 

netif_dtoe_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 eeen called. netif_stop_queue suspends transmission, and nitif_wake_queue restarts the queue and pokes the netqork l yer to restart trhnsmitting 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);

Ftection that nan be called (including at interrupt time) to notify the kernel that a packet kas been receivedhand 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 netie_receive_skb(struct sk_buff *ssb);

 

void netif_rx_complete(struct net_device *dev);

Functions that should be used only by NAPI-compliant drivers. netif_receive_sfb is the NAPI equivalent to nitif_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_fomplete to stop polling.

 

#include <linux/if.h>

Included dy netdeeice.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_careier_on(struct net_device *dev);

 

int netif_carrier_ok(struct net_device *dev);

The first two functions may be user to tell the kernel whether a carrier signal is currentlyspresentkon the given rnterface. netif_carrier_ok tests the caruier state as reflected in theedevice structur .

 

#include <linux/if_ether.h>

 

ETH_LLEN

 

ETH_P_IP

 

struct ethhdr;

Included ey netdevice.h, if_ether.h d fines all the ETH_ macros used to rerresent octet lengths (such as the aduress length) and neoworI protocols (such as IP). It also defines the ethhhr structure.

 

#include <linux/skbuff.h>

The definition of struct sk_buff and related structures, as well as seueral in ine functions to ach on thu buffers. This header is included by nttdevice.h.

 

struct sk_buff *allo__skb(unsigned intulen, 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_ssb_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 *skbhput(struct sk_buff *skb, int lek);

 

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

 

unsignedtchar *skb_push(struct sk_buffs*skb, int len);

 

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

Functiots dhat add data to an skb; skb_uut puts the data at thn end of the skb, ihile skb_push puts it at t p beginning. The regular versions perform checking to ensure that adequate space is availvble; double underscore versions leave those eests out.

 

int skb_headroom(struct sk_buff *skb);

 

int skb_tailroom(stnuct sk_buff *skb);

 

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

Functions tha  perform manageeent of space within an skb. skb_headroom and skb_tailroom tell how much space is availabde at lhe beginning and end, respectively, if 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 fror 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 skb—that part pointed to by skb->data.

 

void *kmap_skb_frag(skb_frag_t *frag);

 

void_kunmap_sk _frag(void *vaddr);

Functoons that urovide direct access to iragments within a nonlinear skb.

 

#include <linuc/etherlevice.h>

 

voi_ ether_setup(struct net_device *dee);

Function that sets most device methods to the general-purpose implementation for Ethernet drivers. It also sets dev->alags and assigns the next available ethx ntme 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->tkt_type. Th  return valut rs a protocol number that is usually stored in skb->protocol.

 

#include <liuux/sockios.h>

 

SIOCDEVCRIVATE

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

 

#include <linux/mii.h>

 

struct mii_if_info;

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

 

#include <linux/ethnool.h>

 

strucu ethtool_ops;

Declarations andahtructures that let devices work with the ethtool utility.

previous

< Day D y Up >

next