{"id":286,"date":"2024-07-14T22:00:03","date_gmt":"2024-07-14T16:30:03","guid":{"rendered":"https:\/\/dctn.in\/?p=286"},"modified":"2024-07-14T22:00:04","modified_gmt":"2024-07-14T16:30:04","slug":"mdio-bus-architecture-in-linux","status":"publish","type":"post","link":"https:\/\/dctn.in\/index.php\/blog\/mdio-bus-architecture-in-linux\/","title":{"rendered":"MDIO BUS architecture in LINUX"},"content":{"rendered":"\n<p class=\"has-very-light-gray-to-cyan-bluish-gray-gradient-background has-background\">In Linux networking and hardware management, the MDIO (Management Data Input\/Output) bus is a communication interface used to manage and control Ethernet PHY (Physical Layer) devices. The MDIO bus allows the host system (such as a network interface controller or a switch controller) to interact with PHY devices for tasks like configuration, monitoring, and diagnostics. MDIO also know as Serial Management Interface. The\u00a0MDIO serial bus is a subset of the MII(Media-independent interface) that is used to transfer management information between MAC and PHY.\u00a0<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Key Components and Functionality:<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>PHY Devices<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Ethernet PHY devices are responsible for transmitting and receiving Ethernet frames over the physical medium (such as twisted pair cables or fiber optics).<\/li>\n\n\n\n<li>Each PHY device has its own unique address on the MDIO bus, allowing the host to communicate with and control multiple PHYs connected to the same MDIO bus.<\/li>\n\n\n\n<li>i.e.  for this DP83822 phy device defined in linux\/drivers\/net\/phy\/dp83822.c<br><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"70\" class=\"wp-image-287\" style=\"width: 150px;\" src=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/driver_code.png\" alt=\"\" srcset=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/driver_code.png 530w, https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/driver_code-300x140.png 300w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/li>\n\n\n\n<li><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>MDIO Bus Interface<\/strong>:\n<ul class=\"wp-block-list\">\n<li>In Linux, the MDIO bus interface is typically implemented using drivers and kernel modules that manage communication between the host system and PHY devices.<\/li>\n\n\n\n<li>It provides functions to read and write PHY registers, which contain configuration settings and status information.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>MDIO Frame Format &#8212; Clause 22<\/strong> <strong>( Basic Communication Frame Format) <\/strong>\n<ul class=\"wp-block-list\">\n<li><a>Clause 22 defines the MDIO communication basic frame format<\/a> and it has following fields<\/li>\n\n\n\n<li><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"41\" class=\"wp-image-288\" style=\"width: 150px;\" src=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/MDIO_MDC_Basic_Frame_Format.png\" alt=\"\" srcset=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/MDIO_MDC_Basic_Frame_Format.png 475w, https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/MDIO_MDC_Basic_Frame_Format-300x82.png 300w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/li>\n\n\n\n<li>Description of each fields are :\n<ul class=\"wp-block-list\">\n<li>ST 2 bits Start of Frame (01 for Clause 22)<\/li>\n\n\n\n<li>OP 2 bits OP Code<\/li>\n\n\n\n<li>PHYADR 5 bits PHY Address<\/li>\n\n\n\n<li>REGADR 5 bits Register Address<\/li>\n\n\n\n<li>TA 2 bits Turnaround time to change bus ownership from STA to MMD if required<\/li>\n\n\n\n<li>DATA 16 bits Data<\/li>\n\n\n\n<li>Driven by STA during write<\/li>\n\n\n\n<li>Driven by MMD during read<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong><a>Clause 45<\/a> &#8211; (Extended MDIO Frame Format)<\/strong><\/li>\n\n\n\n<li><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"57\" class=\"wp-image-289\" style=\"width: 150px;\" src=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/MDIO_extended_Frame_Format.png\" alt=\"\" srcset=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/MDIO_extended_Frame_Format.png 452w, https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/MDIO_extended_Frame_Format-300x113.png 300w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/li>\n\n\n\n<li>below are the fields details of a particular frame  \n<ul class=\"wp-block-list\">\n<li>ST 2 bits Start of Frame (00 for Clause 45)<\/li>\n\n\n\n<li>OP 2 bits OP Code<\/li>\n\n\n\n<li>PHYADR 5 bits PHY Address<\/li>\n\n\n\n<li>DEVTYPE 5 bits Device Type<\/li>\n\n\n\n<li>TA 2 bits Turnaround time to change bus ownership from STA to MMD if required<\/li>\n\n\n\n<li>ADDR\/DATA 16 bits Address or Data<\/li>\n\n\n\n<li>Driven by STA for address<\/li>\n\n\n\n<li>Driven by STA during write<\/li>\n\n\n\n<li>Driven by MMD during read<\/li>\n\n\n\n<li>Driven by MMD during read-increment-address<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Usage Scenarios<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong>Auto-Negotiation<\/strong>: The MDIO bus is used during the auto-negotiation process between network devices to determine the highest possible speed and duplex mode supported by both ends of the link.<\/li>\n\n\n\n<li><strong>Link Monitoring<\/strong>: Allows the host to monitor link status, detect cable faults, and adjust settings dynamically.<\/li>\n\n\n\n<li><strong>PHY Configuration<\/strong>: Enables setting PHY-specific parameters such as speed, duplex mode, flow control settings, etc.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Linux Kernel Support<\/strong>:\n<ul class=\"wp-block-list\">\n<li>The Linux kernel provides MDIO bus drivers and a framework for managing PHY devices. These drivers are typically part of the networking subsystem and are responsible for initializing MDIO controllers and handling communication with PHYs.<br><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"117\" class=\"wp-image-290\" style=\"width: 150px;\" src=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/MDIO_BUS_Init.png\" alt=\"\" srcset=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/MDIO_BUS_Init.png 602w, https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/MDIO_BUS_Init-300x233.png 300w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/li>\n\n\n\n<li>MDIO bus initialized code present at below path drivers\/net\/phy\/mdio_bus.c <\/li>\n\n\n\n<li>Users can interact with the MDIO bus and PHY devices through utilities like <code>ethtool<\/code> and system libraries that expose MDIO bus operations.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">i.e. For Example<\/h3>\n\n\n\n<p>In practical uses, if you have a network interface card (NIC) with multiple Ethernet ports, each port might have its own PHY device connected via the MDIO bus. The Linux kernel&#8217;s MDIO bus drivers would facilitate communication between the NIC and these PHYs, allowing the kernel to configure network settings and monitor link status as needed.<\/p>\n\n\n\n<p>For more details about the Frame Format Please refer to following links <\/p>\n\n\n\n<p><a href=\"https:\/\/www.ieee802.org\">https:\/\/www.ieee802.org<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux networking and hardware management, the MDIO (Management Data Input\/Output) bus is a communication interface used to manage and control Ethernet PHY (Physical Layer) devices. The MDIO bus allows the host system (such as a network interface controller or a switch controller) to interact with PHY devices for tasks like configuration, monitoring, and diagnostics. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-blog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/comments?post=286"}],"version-history":[{"count":2,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":292,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts\/286\/revisions\/292"}],"wp:attachment":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/media?parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/categories?post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/tags?post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}