PHY Linux Driver

Source: Internet
Author: User

Ethernet Mac (link layer) +phy (physical layer/rtl8201f,88e1111), integrated DM9000,RTL8139CP because of the large amount of network data transmission, whether it is a separate type or integrated, it usually introduces DMA between MAC and PHY. Mac and PHY are separated because the Mac is part of the digital circuit, and the PHY is part of the simulation, responsible for the data received to the MAC layer, the MAC layer will receive the data transferred to the upper layer protocol, such as the IP layer, IGMP layer. The PHY layer is also responsible for converting the data sent by the MAC layer into a differential signal, which is then fed into the RJ45 connector's cable after the transformer behind it. The corresponding data format is: Leader + start bit + Destination MAC address + source MAC address + type length + data +padding (optional) +32bit CRC PHY layer is responsible for more tasks, such as the choice of 10m/100m rate; full or half duplex , carrier interception and collision detection, which corresponds to a specific chip is a set of internal registers. The PHY function module and the MCU link are linked in Mii/rmii mode so that the relevant registers can be set using the MCU. Mii is 16 lines, RMII will send and receive data lines to reduce to two, which involves string and conversion, will be the MCU class of the parallel bus eventually converted to the RJ45 line transmission of single bit encoding. 100M is Manchester code, 10M is NRZ encoding, this type of code mainly consider load balancing and error correction. Also brings additional network overhead. PHY layer initialization, mainly two parts, one is the initialization of the Mdio bus, one is the PHY driver initialization, for the usual can use the default kernel of the PHY driver, However, if the internal register of the PHY chip is not the same as the 802.3 definition, it is necessary to implement the driver itself, such as 8201 of the hundred-rate PHY chip can use the default PHY driver, but for some of the more powerful integration of multiple PHY switch, usually the driver may need to implement, switch often A network that is used for higher rates of transmission or VLAN. The PHY layer starts with the driver/net/phy/phy_device.c file. Subsys_initcall (Phy_init); Module_exit (Phy_exit); See also Subsys_initcall, which indicates that it was completed at system initialization, static int __init phy_init (void) {int rc; rc = Mdio_bus_init (); if (RC) return RC; RC = Phy_driver_register (&genPhy_driver); if (RC) Mdio_bus_exit (); return RC; }。 The drive involves several important parts: Bus-sturct Mii_bus (Mii stand for media independent interface) device-struct Phy_device drive-struct phy_driver Mdiobus_register------The probe function calls, creates the bus, then scans the device above it and, if found, creates the device. _|_ drovers\net\phy\mdio_bus.c drivers\net\phy\phy_device.c struct phy_device *mdiobus_scan (struct Mii_bus * bus, int Addr)----Get_phy_device--phy_device_create | | DRIVERS\BASE\CORE.C----Device_register---device_add (kobject_add build device tree) driver calls Phy_driver_register to register the driver, This is the PHY drive will also form a linked list, where the reason is not a tree and the upper device becomes a tree, because Mii may be mounted on the PCI bus, of course, there may be other devices on the PCI, these devices and PHY devices are not on a linked list, but through the kobject link management, corresponding to the A kset,kset is actually a collection of Kobject, the same Kobject object will point to the same kset, such as a USB mouse, the keyboard belongs to the same kset set. The above bus, device, and driver (assuming that the driver has been written, most of the driver will have an identifier, for the time being as an ID, this ID refers to the device it supports); If hot-swappable is not supported, the system scans the device and concatenates it into the device tree when it is started. When the driver registers (register), the driver will go to the device tree, look for the ID number and its corresponding equal, if found, then the two are bundled together, usually the XXX_ATTCAH function, the application layer of the device will be the operation of the call driver into the corresponding read, write, IOCTL and so on. If hot-swappable is supported, it is more complicated than the above, because the driver may exist before the device (bus), so when there is a new hardware connection, the kernel calls the Xxx_probe function to probe, registers the device, and then goes to the drive list to find the driver, and if it finds it, attach. On itsThe operation method is the same as above. The remaining problem is the writing of the driver.

PHY Linux Driver

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.