[ale] Help on Device driver hacking

Ray Knight audilover at atlantabroadband.com
Wed May 21 23:55:49 EDT 2003


On Wed, 2003-05-21 at 10:21, AMIT AGRAWAL wrote:
> I am wishing to know if anyone has worked on redirecting Disk I/O to the NIC
> using the VFS.
> 
No experience here.

> Also can somebody guide me(or give a few hints/references) on how to program
> a NIC device driver to record number/size of packets transferred over the
> NIC.
> 
You must allocate a dev->priv with a sizeof a local device structure
which will contain a struct net_device_stats element.  Assuming you name
the structure my_local do the following when transmitting a packet:

struct my_local *lp = (struct my_local *)dev->priv;

lp->stats.tx_bytes += skb->len;
lp->stats.tx_packets++;

For receiving you will increment lp->stats.rx_packets and
lp->stats.rx_byes

See include/linux/netdevice.h for other statistics you can keep track of
in the structure, such as packets dropped, collisions and detailed
errors if your hardware reports them.

> regards
> 
> Amit
> 

Hope this helps.

Ray



_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list