- 论坛徽章:
- 0
|
![]()
init() is used to search and initialize network devices. This method is responsible for finding and initializing a network adapter of the present type. Primarily, a net_device structure has to be created and filled with the driver-specific data of the network device or network driver. Subsequently, the network device is registered by register_netdevice(). (See
Section 5.3.1
.)
uninit() is called when a network device is unregistered (unregister_netdevice()). This method can be used to execute driver-specific functions, which may be necessary when a network device is removed. The uninit() has been introduced to the net_device structure since version 2.4 and is currently not used by any driver.
destructor() is also new in the net_device structure. This function is called when the last reference to a network device was removed (dev->refcnt) (i.e., when no protocol instances or other components in the Linux kernel point to the net_device structure). This means that you can use the destructor() function to do cleanup work (e.g., free memory or similar things). The destructor() function is currently not used by any driver.
open() opens (activates) a named network device. During the activation, the required system resources are requested and assigned. Note that this method can open only network devices that were previously registered. Normally, dev->open() is used in the dev_open() method which, in turn, is called by the ifconfig command. Upon successful execution of open(), the network device can be used.
stop() terminates the activity of a network adapter and frees the system resources it has used. The network device is then no longer active, but it remains in the list of registered network devices (net_devs).
hard_start_xmit() uses a packet (in the form of a socket buffer) over the network device. If successful (i.e., the packet was delivered to the adapter), then hard_start_xmit() returns with the return value 0; otherwise, 1.
get_stats() gets statistics and information about the network device and its activities. This information is returned in the form of a net_device_stats structure. The elements of this structure will be introduced in the course of this chapter.
get_wireless_stats() returns additional information for wireless network adapters. This information is forwarded in a structure of the type iw_statistics. The tool iwconfig can be used to display this specific information.
set_multicast_list() passed the list with multicast MAC addresses to the network adapter, so that the adapter can receive packets with these addresses. This list is called either when the multicast receipt for the network device is activated (IFF_MULTICAST flag) or when the list of group MAC addresses to be received has changed. (See also
Section 17.4.1
.)
watchdog_timeo() deals with problems during the transmission of a packet across the network adapter (not when the socket buffer is passed to the network adapter). If no acknowledgment for the packet is received after dev->tx_timeout, then the kernel calls the method watchdog_timeo() to solve the problem.
do_ioctl(): This method is generally not used by higher protocols, because they have no generic functions. It is normally used to pass adapter-specific ioctl() commands to the network driver.
set_config() is used to change the configuration of a network adapter at runtime. The method lets you change system parameters, such as the interrupt or the memory location of the network adapter.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/79820/showart_1358464.html |
|