Re: what is equivalent to ether_setup in 8139too.c as given in LDD page 504
Ok thanks for your responses. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: what is equivalent to ether_setup in 8139too.c as given in LDD page 504
This functions are helpers for the generic link layers(L2) params setup. For example: /** * ether_setup - setup Ethernet network device * @dev: network device * Fill in the fields of the device structure with Ethernet-generic values. */ void ether_setup(struct net_device *dev) { dev->header_ops = ð_header_ops; dev->type = ARPHRD_ETHER; dev->hard_header_len= ETH_HLEN; dev->mtu= ETH_DATA_LEN; dev->addr_len = ETH_ALEN; dev->tx_queue_len = 1000; /* Ethernet wants good queues */ dev->flags = IFF_BROADCAST|IFF_MULTICAST; memset(dev->broadcast, 0xFF, ETH_ALEN); } or for the FDDI: static void fddi_setup(struct net_device *dev) { dev->header_ops = &fddi_header_ops; dev->type = ARPHRD_FDDI; dev->hard_header_len= FDDI_K_SNAP_HLEN+3; /* Assume 802.2 SNAP hdr len + 3 pad bytes */ dev->mtu= FDDI_K_SNAP_DLEN; /* Assume max payload of 802.2 SNAP frame */ dev->addr_len = FDDI_K_ALEN; dev->tx_queue_len = 100; /* Long queues on FDDI */ dev->flags = IFF_BROADCAST | IFF_MULTICAST; memset(dev->broadcast, 0xFF, FDDI_K_ALEN); } On Fri, Nov 5, 2010 at 3:05 PM, Tapas Mishra wrote: > I am trying to understand how network drivers can be written. > In LDD page 504 Chapter 17, > what is equivalent to ether_setup in 8139too.c as given in LDD page 504 > a function ether_setup has been explained what is equivalent to that > function in the driver > 8139too.c > > -- > http://mightydreams.blogspot.com > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecar...@nl.linux.org > Please read the FAQ at http://kernelnewbies.org/FAQ > > -- Regards, Denis -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: what is equivalent to ether_setup in 8139too.c as given in LDD page 504
Hi Tapas, On Fri, Nov 5, 2010 at 2:05 PM, Tapas Mishra wrote: > I am trying to understand how network drivers can be written. > In LDD page 504 Chapter 17, > what is equivalent to ether_setup in 8139too.c as given in LDD page 504 > a function ether_setup has been explained what is equivalent to that > function in the driver > 8139too.c Understanding your question was harder than finding the answer :). As LDD3 describes in Chapter 17, one step in writing a network driver is allocating a structure called net_dev. This structure is associated with a specific interface and must be properly initialized before registering it with the kernel. Allocating a net_dev object can be performed in general by calling the function alloc_netdev(..,.., setup) [1]. After allocating a net_dev object this function will call setup to finish the initialization. Anyhow, alloc_netdev is a generic function and you must have your own setup implementation. In order to speed up the implementation the kernel offers some helper functions for the most common interface types. One of the helper functions is for Ethernet interfaces - alloc_etherdev ([2]). This function has its own setup function called ether_setup ([3]). Now the answer to your question: The equivalent of ether_setup from LDD page 504, inside the 8139too.c file is ether_setup :). The only difference is that in LDD ether_setup is called manually inside snull_init, while in 8139too.c ether_setup is wrapped in the call for alloc_etherdev. thanks, Daniel [1] http://lxr.linux.no/#linux+v2.6.36/include/linux/netdevice.h#L2078 [2] http://lxr.linux.no/#linux+v2.6.36/include/linux/etherdevice.h#L52 [3] http://lxr.linux.no/#linux+v2.6.36/net/ethernet/eth.c#L334 -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
what is equivalent to ether_setup in 8139too.c as given in LDD page 504
I am trying to understand how network drivers can be written. In LDD page 504 Chapter 17, what is equivalent to ether_setup in 8139too.c as given in LDD page 504 a function ether_setup has been explained what is equivalent to that function in the driver 8139too.c -- http://mightydreams.blogspot.com -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ