匿名
未登录
登录
百问网嵌入式Linux wiki
搜索
查看“Ethernet overview”的源代码
来自百问网嵌入式Linux wiki
名字空间
页面
讨论
更多
更多
页面选项
Read
查看源代码
历史
←
Ethernet overview
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
This article gives information about the Linux<sup>®</sup> Ethernet framework, provides its composition and explains how to configure and use it. == Framework purpose == '''以太网'''是将局域网或局域网中的设备连接在一起的一种方式。 以太网协议用于传输包含任何信息的数据包。 连接到网络的任何两个设备都可以通过以太网连接交换信息。 以太网提供了到路由器的快速,有效和直接的连接。 以太网可以用于许多不同的用例中,如 [[#How to use Ethernet|How to use Ethernet]] 部分所述: * 如何进行远程连接 [[How to perform ssh connection|SSH]] * 如何执行ping测试 [[How to perform ping test|PING]] ==System overview== [[File:Ethernet_overview.png|thumb|center|766px|link=|alt=Alternate text|Ethernet Overview]] ===Component description=== ''从用户空间到硬件'' *'''应用''' (用户空间) 有很多使用以太网的应用程序: Internet浏览器,流应用程序,FTP应用程序等。<br /> 在应用程序和网络协议之间使用的主要接口是套接字 <ref>[https://en.wikipedia.org/wiki/Berkeley_sockets], Berkeley sockets</ref> *'''Ethernet工具''' (用户空间) 一组实用程序可用于管理和维护网络:ethtool,ping,路由,ifconfig等。 *'''Linux套接字层和网络协议''' (内核空间) 套接字层是 <ref>[https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/net/socket.c], Socket Layer</ref> 一个统一的接口。 在用户进程和网络协议 <ref>[https://en.wikipedia.org/wiki/Internet_Protocol], Internet Protocol</ref>堆栈在内核中 *'''Linux网络核心''' (内核空间) 内核网络层使用正在使用的传输协议来调整消息。 Linux内核的网络子系统设计为完全独立于协议。 *'''Stmmac驱动程序''' (内核空间) 这是MAC 10/100/1000片上以太网控制器的驱动程序 (Synopsys IP块).<br /> Documentation/networking/stmmac.txt<ref>https://www.kernel.org/doc/Documentation/networking/stmmac.txt, More information</ref> *'''ETH''' (硬件) 这是 Ethernet IP: GMAC <ref>[https://www.synopsys.com/dw/ipdir.php?ds=dwc_ether_mac10_100_1000_unive], DesignWare Ethernet GMAC IP</ref> *'''Ethernet phy(以太网物理层)''' (硬件) 以太网PHY连接到媒体访问控制器(MAC)。 MAC控制OSI模型的数据链路层部分。<br /> 媒体无关接口(MII)定义了MAC与PHY之间的接口。<br /> 提供MII的变体(RGMII,GMII,RMII,MII),根据系统要求,它们提供的针脚数量最少且数据速率不同<br /> MDIO总线包含两个信号:<br /> - MDC clock: 由MAC设备驱动到PHY。<br /> - MDIO data: 双向,它由PHY驱动,以在读取操作结束时提供寄存器数据。<br /> 以太网phy使用的连接器是RJ45。 ===API description=== 以太网API记录在Linux内核中 https://www.kernel.org/doc/html/v4.14/networking/kapi.html ==Configuration == ===Kernel configuration=== The Ethernet API is activated by default in ST deliveries. Nevertheless, if a specific configuration is required, one can use Linux Menuconfig tool: [[Menuconfig or how to configure kernel | Menuconfig or how to configure kernel ]] and select: For Network features: <pre> [*] Networking support ---> [*] Networking options ---> [*] Packet socket [*] TCP/IP networking [*] IP: kernel level autoconfiguration [*] IP: DHCP support [*] IP: BOOTP support [*] IP: RARP support [*] INET: socket monitoring interface [*] The IPv6 protocol [*] DNS Resolver support </pre> For Phy (Generic PHY support) : <pre> [*] Device Drivers ---> [*] PHY Subsystem ---> [*] PHY Core </pre> For STM32 DWMAC : <pre> [*] Device Drivers ---> [*] Network device support ---> [*] Ethernet driver support ---> [*] STMicroelectronics devices [*] STMicroelectronics 10/100/1000/EQOS Ethernet driver [*] STMMAC Platform bus support [*] Generic driver for DWMAC [*] STM32 DWMAC support </pre> ===Device tree configuration=== DT bindings documentation deals with all required or optional [[Device tree|device tree]] properties. Detailed DT configuration for STM32 internal peripherals: [[Ethernet device tree configuration|Ethernet device tree configuration]]. ==How to use Ethernet == === How to use the Ethernet user space interface === Please see examples based on the following use cases: * How to configure ethernet interface: [[How to configure ethernet interface|How to configure ethernet interface]] * How to perform ssh connection: [[How to perform ssh connection|How to perform ssh connection]] * How to perform ping test: [[How to perform ping test|How to perform ping test]] ==How to trace and debug the framework== === How to monitor === ==== How to monitor with sysfs ==== '''sysfs''' entry can be used to browse for available descriptors and hardware capabilies. {{Board$}} /sys/kernel/debug/stmmaceth/eth0# ls descriptors_status dma_cap root@stm32mp1://sys/kernel/debug/stmmaceth/eth0# cat descriptors_status RX Queue 0: Descriptor ring: 0 [0xf4e8d000]: 0xecb01842 0x0 0x0 0x81000000 1 [0xf4e8d010]: 0xecb02042 0x0 0x0 0x81000000 .... root@stm32mp1://sys/kernel/debug/stmmaceth/eth0# cat dma_cap ============================== DMA HW features ============================== 10/100 Mbps: Y 1000 Mbps: Y Half duplex: Y Hash Filter: Y Multiple MAC address registers: Y PCS (TBI/SGMII/RTBI PHY interfaces): N SMA (MDIO) Interface: Y PMT Remote wake up: Y PMT Magic Frame: Y RMON module: Y IEEE 1588-2002 Time Stamp: N IEEE 1588-2008 Advanced Time Stamp: Y 802.3az - Energy-Efficient Ethernet (EEE): Y AV features: Y Checksum Offload in TX: Y IP Checksum Offload in RX: Y RXFIFO > 2048bytes: N Number of Additional RX channel: 1 Number of Additional TX channel: 2 Enhanced descriptors: N ====Other ways of monitoring==== [[Ethtool|Ethtool]] is a Linux-based utility for displaying and modifying some parameters of the network interface controllers (NICs) and their device drivers. {{Board$}} ethtool eth0 Settings for eth0: Supported ports: [ TP AUI BNC MII FIBRE ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Supported pause frame use: Symmetric Receive-only Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Link partner advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Link partner advertised pause frame use: Symmetric Link partner advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: MII PHYAD: 0 Transceiver: internal Auto-negotiation: on Supports Wake-on: ug Wake-on: d Current message level: 0x0000003f (63) drv probe link timer ifdown ifup Link detected: yes === How to trace === The Ethernet Framework (and specifically the stmmac driver) prints out information and error messages in the kernel console. They are available via dmesg command: {{Board$}} '''dmesg | grep ethernet''' [ 1.454632] stm32-dwmac 5800a000.ethernet: PTP uses main clock [ 1.459010] stm32-dwmac 5800a000.ethernet: no reset control found [ 1.465199] stm32-dwmac 5800a000.ethernet: No phy clock provided... [ 1.472347] stm32-dwmac 5800a000.ethernet: User ID: 0x40, Synopsys ID: 0x42 [ 1.478319] stm32-dwmac 5800a000.ethernet: DWMAC4/5 [ 1.483310] stm32-dwmac 5800a000.ethernet: DMA HW capability register supported [ 1.490564] stm32-dwmac 5800a000.ethernet: RX Checksum Offload Engine supported [ 1.497888] stm32-dwmac 5800a000.ethernet: TX Checksum insertion supported [ 1.504753] stm32-dwmac 5800a000.ethernet: Wake-Up On Lan supported [ 1.510994] stm32-dwmac 5800a000.ethernet: TSO supported [ 1.516329] stm32-dwmac 5800a000.ethernet: TSO feature enabled [ 1.522143] stm32-dwmac 5800a000.ethernet: Enable RX Mitigation via HW Watchdog Timer [ 12.356485] stm32-dwmac 5800a000.ethernet eth0: No Safety Features support found [ 12.426208] stm32-dwmac 5800a000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported [ 12.481051] stm32-dwmac 5800a000.ethernet eth0: registered PTP clock [ 14.951370] stm32-dwmac 5800a000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx It is possible to modify the amount of 'debugging messages/data' returned by the Ethernet driver with ethtool. More documentation is available in Documentation/networking/netif-msg.txt<ref>[https://www.kernel.org/doc/Documentation/networking/netif-msg.txt], Documentation/networking/netif-msg.txt</ref> in kernel source folder. Ethtool to set the message level: {{Board$}} '''ethtool -s eth1 msglvl [level]''' === How to debug === During Ethernet bring up, there are 2 frequent errors: * DMA reset error: [ 15.650981] dwmac4_dma_reset err [ 15.652849] stm32-dwmac 5800a000.ethernet: Failed to reset the dma [ 15.659006] stm32-dwmac 5800a000.ethernet eth0: stmmac_hw_setup: DMA engine initialization failed [ 15.668518] stm32-dwmac 5800a000.ethernet eth0: stmmac_open: Hw setup failed When this error occurs, it is linked to the DMA Software Reset (not linked to memory transfert)<br /> Definition of the Software Reset in GMAC specification: When this bit is set, the MAC and the DMA controller reset the logic and all internal registers of the DMA, MTL, and MAC. This bit is automatically cleared after the reset operation is complete in all DWC_ether_qos clock domains. Before reprogramming any DWC_ether_qos register, a value of zero should be read in this bit. *Note*: The reset operation is complete only when all resets in all active clock domains are de-asserted. Therefore, it is essential that all PHY inputs clocks (applicable for the selected PHY interface) are present for software reset completion. The time to complete the software reset operation depends on the frequency of the slowest active clock. Access restriction applies. Setting 1 sets. Self-cleared. Setting 0 has no effect. *Ethernet clock tree error: The GMAC IP verifies that the Ethernet clock tree is well configured. When this error occurs, it is due to the Ethernet PHY that do not detect all needed clocks (tx, rx, aclk or hclk). To solve this issue: - check that the pinctrl of each clock is well configured - check if syscfg register is well configured (in Ethernet clock tree there are some gating/mux configured with syscfg) ==Source code location== The source files are located inside the Linux kernel. *'''Ethernet driver''': dwmac-stm32.c<ref>[https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c],dwmac-stm32.c</ref> ==References== <references />
该页面使用的模板:
模板:Board$
(
查看源代码
)
返回至
Ethernet overview
。
导航
导航
WIKI首页
官方店铺
资料下载
交流社区
所有页面
所有产品
MPU-Linux开发板
MCU-单片机开发板
Linux开发系列视频
单片机开发系列视频
所有模块配件
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志