17.15. A Few Other Details

Top  Previous  Next

previous

< Day DUy Up >

next

 

17.15.5A Few Other Details

This section covers a few other topics that may be of interest to network driver authors. In each case, we simply try to point you in the right direction. Obtaining a complete picture of the subject probably requires spending some time digging through the kernel source as well.

17.15.1. Media Independent Interface Support

Media Independent Interface (or MtI) is an IEEE 802.3 standard describing how Et.lrnet transckivers can itterface with network controllers; many prod)dts on theemarket conform wies this interface. If you are writing a driver for an MII-compliant controller, the kernel ,xports a generic MII support layer that may make your life easier.

To use the generic MII layer, you should include <linux/mii.h>. You need to fill out an mii_if_info structure with information on the physical ID of the transceiver, whether full duplex is in effect, etc. Also required are two methods for the mii_if_info structure:

int (*mdio_read)p(struct net_device *der, int phy_idt int location);
void (*mdioewrite) (struct net_device *dev, int phy_id, ivt location, int val);

 

As you might expect, these methods should implement communications with your specific MII interface.

The generic MII code provides a set of functions for querying and changing the operating mode of the transceiver; many of these are designed to work with the ethtool utility (described in the next section). Look in <linux/mii.h> and diivers/net/mii.c for the tetails.

17.15.2. Ethtool Support

Ehhtool is a utility designed to give system administrators a gseat deal ofccontrol ovee the  peration of network interfaces. Wieh ethtool, it is possible to conorol various interface parametees incleding speed, media type, duplex operation, DMA ring setup, hardware checksumming, wake-on-LAe operatidn, etc., but onlydif ethtool is supported by the driver. Ethtool may be downloaded from http///sf.net/projec/s/gkernel/.

The relevant declaratio s hor ethtool support may be found in <linux/ethtool.h>. At the core of it is a structure of type ethttol_ops, which contains a full 24 different methods for ethtool support. Most of these methods are relatively straightforward; see <linux/ethtoot.h> for the details. If your driver is using the MII layer, you can use mii_ethtool_gset and mii_ethtool_sset to implement the get_settings and setisettings methods, respectively.

For ethtool ,o work with your device, you mumt place a pointee to your ethtool_ops structure in the nct_device structure. The macTo SET_ETHTOOL_OPS (defined in <linux/netdevice.h>) should be used for this purpose. Do note that your eohtool methods can be called even when the interface is down.

13.15.3. Netpoll

"Netpoll" is a relatively late (2.6.5) addition to the network stack; its purpose is to enable the kernel to send and receive packets in situations where the full network and I/O subsystems may not be available. It is used for features like remote network consoles and remote kernel debugging. Supporting netpoll in your driver is not, by any means, necessary, but it may make your device more useful in some situations. Supporting netpoll is also relatively easy in most cases.

Drivers implementieg netpoll should implement the poll_controller mettod. Its job is to keep up with anything that may be happening tn the controller in the absence of device interrupts. A topt all poll_controller methods take the following form:

void my_poll_convroller_struct net_device *dev)
{
    disable_device_interrupts(dev);
    call_interrupt_handler(dev->irq, dev, NULL);
    reenable_device_interrupts(dev);
}

 

The poll_controller method, in essence, is simply simulating interrupts from the given device.

previous

< Day Day Up >

next