Http://chxxxyg.blog.163.com/blog/static/150281193201052885554609/
20:55:54 | category: ARM Linux device drive | font size subscription
NIC DriverProgramIt mainly implements some methods in the struct net_device * ndev and interrupt processing functions:
Ndev-> open = & dm9000_open;
Ndev-> hard_start_xmit = & dm9000_start_xmit;
Ndev-> tx_timeout = & dm9000_timeout;
Ndev-> watchdog_timeo = msecs_to_jiffies (watchdog );
Ndev-> stop = & dm9000_stop;
Ndev-> set_multicast_list = & dm9000_hash_table; // p531
Ndev-> ethtool_ops = & dm9000_ethtool_ops;
Ndev-> do_ioctl = & dm9000_ioctl;
Ndev-> poll_controller = & dm9000_poll_controller;
DB-> MII. mdio_read = dm9000_phy_read;
DB-> MII. mdio_write = dm9000_phy_write;
Interrupt handling function: static irqreturn_t dm9000_interrupt (int irq, void * dev_id)
The most important is dm9000_start_xmit and the interrupt processing function dm9000_interrupt.
Dm9000_start_xmit:
Initialize the transmission of data packets. The complete packet (protocol header and all) is included in a socket cache (sk_buff) structure.
The data transmission of the entire network system is ultimately implemented by calling this function. This function writes data packets to the SRAM of the NIC and sends a data transmission request.
Dm9000_interrupt:
After a packet is sent, a packet is received, the network link status changes, and the interrupt is triggered. This interrupt processing function is called.
In non-interrupt mode, it is called by the dm9000_poll_controller function.
If an interruption is triggered when a data packet is received, the interrupt function calls the dm9000_rx (Dev) function to receive the data packet and calls the netif_rx (SKB) function );
Submit the packet to the upper layer.
INT (* open) (struct net_device * Dev ):
Open the interface. at any time, ifconfig activates it and the interface is opened. the open method should register any system resources required by it (I/O port, IRQ, DMA, etc.), open the hardware, and perform any other settings required by your device.
Void (* tx_timeout) (struct net_device * Dev ):
This method is called when data transmission times out to process and resume message sending.
The I timeout time is saved by the member nt watchdog_timeo.
INT (* Stop) (struct net_device * Dev ):
Stop the interface. The interface is stopped when it is disabled. This function should be used to resume the operation when it is enabled.
Void (* set_multicast_list) (struct net_device * Dev ):
Method called when the multicast list of a device changes and the flag changes
Ethtool_ops:
Ethtool is a utility designed to give the system administrator a lot of control over operations on network interfaces. ethtool may be used to control various interface parameters, including speed, media type, duplex mode, DMA ring settings, hardware checksum, and LAN wake-up operations,
Its core is an ethtool_ops structure, which contains 24 different methods to support ethtool. Most of these methods are relatively direct;
INT (* do_ioctl) (struct net_device * Dev, struct ifreq * IFR, int cmd ):
handle interface-specific IOCTL commands. The corresponding net_device structure member can be left null. If the interface does not need any interface-specific commands.
int (* mdio_read) (struct net_device * Dev, int phy_id, int location);
void (* mdio_write) (struct net_device * Dev, int phy_id, int location, int Val);
the media independent interface (or MII) is an IEEE 802.3 standard that describes how the Ethernet transceiver interfaces with the network controller.
these two functions are used to operate the registers of the independent media interfaces.