1 .. SPDX-License-Identifier: GPL-2.0+
3 ==============================================================
4 Linux Driver for the Synopsys(R) Ethernet Controllers "stmmac"
5 ==============================================================
7 Authors: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
8 Alexandre Torgue <alexandre.torgue@st.com>, Jose Abreu <joabreu@synopsys.com>
15 - Kernel Configuration
16 - Command Line Parameters
17 - Driver Information and Notes
24 This file describes the stmmac Linux Driver for all the Synopsys(R) Ethernet
27 Currently, this network device driver is for all STi embedded MAC/GMAC
28 (i.e. 7xxx/5xxx SoCs), SPEAr (arm), Loongson1B (mips) and XILINX XC2V3000
29 FF1152AMT0221 D1215994A VIRTEX FPGA board. The Synopsys Ethernet QoS 5.0 IPK
32 DesignWare(R) Cores Ethernet MAC 10/100/1000 Universal version 3.70a
33 (and older) and DesignWare(R) Cores Ethernet Quality-of-Service version 4.0
34 (and upper) have been used for developing this driver as well as
35 DesignWare(R) Cores XGMAC - 10G Ethernet MAC.
37 This driver supports both the platform bus and PCI.
39 This driver includes support for the following Synopsys(R) DesignWare(R)
40 Cores Ethernet Controllers and corresponding minimum and maximum versions:
42 +-------------------------------+--------------+--------------+--------------+
43 | Controller Name | Min. Version | Max. Version | Abbrev. Name |
44 +===============================+==============+==============+==============+
45 | Ethernet MAC Universal | N/A | 3.73a | GMAC |
46 +-------------------------------+--------------+--------------+--------------+
47 | Ethernet Quality-of-Service | 4.00a | N/A | GMAC4+ |
48 +-------------------------------+--------------+--------------+--------------+
49 | XGMAC - 10G Ethernet MAC | 2.10a | N/A | XGMAC2+ |
50 +-------------------------------+--------------+--------------+--------------+
52 For questions related to hardware requirements, refer to the documentation
53 supplied with your Ethernet adapter. All hardware requirements listed apply
59 The following features are available in this driver:
60 - GMII/MII/RGMII/SGMII/RMII/XGMII Interface
61 - Half-Duplex / Full-Duplex Operation
62 - Energy Efficient Ethernet (EEE)
63 - IEEE 802.3x PAUSE Packets (Flow Control)
65 - IEEE 1588 Timestamping (PTP)
66 - Pulse-Per-Second Output (PPS)
67 - MDIO Clause 22 / Clause 45 Interface
70 - Automatic CRC / PAD Insertion and Checking
71 - Checksum Offload for Received and Transmitted Packets
72 - Standard or Jumbo Ethernet Packets
73 - Source Address Insertion / Replacement
74 - VLAN TAG Insertion / Replacement / Deletion / Filtering (HASH and PERFECT)
75 - Programmable TX and RX Watchdog and Coalesce Settings
76 - Destination Address Filtering (PERFECT)
77 - HASH Filtering (Multicast)
78 - Layer 3 / Layer 4 Filtering
79 - Remote Wake-Up Detection
80 - Receive Side Scaling (RSS)
81 - Frame Preemption for TX and RX
82 - Programmable Burst Length, Threshold, Queue Size
83 - Multiple Queues (up to 8)
84 - Multiple Scheduling Algorithms (TX: WRR, DWRR, WFQ, SP, CBS, EST, TBS;
87 - TCP / UDP Segmentation Offload (TSO, USO)
89 - Safety Features (ECC Protection, Data Parity Protection)
90 - Selftests using Ethtool
95 The kernel configuration option is ``CONFIG_STMMAC_ETH``:
96 - ``CONFIG_STMMAC_PLATFORM``: is to enable the platform driver.
97 - ``CONFIG_STMMAC_PCI``: is to enable the pci driver.
99 Command Line Parameters
100 =======================
102 If the driver is built as a module the following optional parameters are used
103 by entering them on the command line with the modprobe command using this
104 syntax (e.g. for PCI module)::
106 modprobe stmmac_pci [<option>=<VAL1>,<VAL2>,...]
108 Driver parameters can be also passed in command line by using::
110 stmmaceth=watchdog:100,chain_mode=1
112 The default value for each parameter is generally the recommended setting,
113 unless otherwise noted.
117 :Valid Range: 5000-None
120 This parameter overrides the transmit timeout in milliseconds.
124 :Valid Range: 0-16 (0=none,...,16=all)
127 This parameter adjusts the level of debug messages displayed in the system
135 This parameter overrides the physical address of the PHY device.
139 :Valid Range: 0-3 (0=off,1=rx,2=tx,3=rx/tx)
142 This parameter changes the default Flow Control ability.
146 :Valid Range: 0-65535
147 :Default Value: 65535
149 This parameter changes the default Flow Control Pause time.
156 This parameter changes the default HW FIFO Threshold control value.
160 :Valid Range: 1536-16384
163 This parameter changes the default RX DMA packet buffer size.
170 This parameter changes the default LPI TX Expiration time in milliseconds.
174 :Valid Range: 0-1 (0=off,1=on)
177 This parameter changes the default mode of operation from Ring Mode to
180 Driver Information and Notes
181 ============================
186 The xmit method is invoked when the kernel needs to transmit a packet; it sets
187 the descriptors in the ring and informs the DMA engine that there is a packet
188 ready to be transmitted.
190 By default, the driver sets the ``NETIF_F_SG`` bit in the features field of
191 the ``net_device`` structure, enabling the scatter-gather feature. This is
192 true on chips and configurations where the checksum can be done in hardware.
194 Once the controller has finished transmitting the packet, timer will be
195 scheduled to release the transmit resources.
200 When one or more packets are received, an interrupt happens. The interrupts
201 are not queued, so the driver has to scan all the descriptors in the ring
202 during the receive process.
204 This is based on NAPI, so the interrupt handler signals only if there is work
205 to be done, and it exits. Then the poll method will be scheduled at some
208 The incoming packets are stored, by the DMA, in a list of pre-allocated socket
209 buffers in order to avoid the memcpy (zero-copy).
214 The driver is able to mitigate the number of its DMA interrupts using NAPI for
215 the reception on chips older than the 3.50. New chips have an HW RX Watchdog
216 used for this mitigation.
218 Mitigation parameters can be tuned by ethtool.
223 Wake up on Lan feature through Magic and Unicast frames are supported for the
224 GMAC, GMAC4/5 and XGMAC core.
229 Driver handles both normal and alternate descriptors. The latter has been only
230 tested on DesignWare(R) Cores Ethernet MAC Universal version 3.41a and later.
232 stmmac supports DMA descriptor to operate both in dual buffer (RING) and
233 linked-list(CHAINED) mode. In RING each descriptor points to two data buffer
234 pointers whereas in CHAINED mode they point to only one data buffer pointer.
235 RING mode is the default.
237 In CHAINED mode each descriptor will have pointer to next descriptor in the
238 list, hence creating the explicit chaining in the descriptor itself, whereas
239 such explicit chaining is not possible in RING mode.
244 The extended descriptors give us information about the Ethernet payload when
245 it is carrying PTP packets or TCP/UDP/ICMP over IP. These are not available on
246 GMAC Synopsys(R) chips older than the 3.50. At probe time the driver will
247 decide if these can be actually used. This support also is mandatory for PTPv2
248 because the extra descriptors are used for saving the hardware timestamps and
254 Ethtool is supported. For example, driver statistics (including RMON),
255 internal errors can be taken using::
259 Ethtool selftests are also supported. This allows to do some early sanity
260 checks to the HW using MAC and PHY loopback mechanisms::
264 Jumbo and Segmentation Offloading
265 ---------------------------------
267 Jumbo frames are supported and tested for the GMAC. The GSO has been also
268 added but it's performed in software. LRO is not supported.
273 TSO (TCP Segmentation Offload) feature is supported by GMAC > 4.x and XGMAC
274 chip family. When a packet is sent through TCP protocol, the TCP stack ensures
275 that the SKB provided to the low level driver (stmmac in our case) matches
276 with the maximum frame len (IP header + TCP header + payload <= 1500 bytes
277 (for MTU set to 1500)). It means that if an application using TCP want to send
278 a packet which will have a length (after adding headers) > 1514 the packet
279 will be split in several TCP packets: The data payload is split and headers
280 (TCP/IP ..) are added. It is done by software.
282 When TSO is enabled, the TCP stack doesn't care about the maximum frame length
283 and provide SKB packet to stmmac as it is. The GMAC IP will have to perform
284 the segmentation by it self to match with maximum frame length.
286 This feature can be enabled in device tree through ``snps,tso`` entry.
288 Energy Efficient Ethernet
289 -------------------------
291 Energy Efficient Ethernet (EEE) enables IEEE 802.3 MAC sublayer along with a
292 family of Physical layer to operate in the Low Power Idle (LPI) mode. The EEE
293 mode supports the IEEE 802.3 MAC operation at 100Mbps, 1000Mbps and 1Gbps.
295 The LPI mode allows power saving by switching off parts of the communication
296 device functionality when there is no data to be transmitted & received.
297 The system on both the side of the link can disable some functionalities and
298 save power during the period of low-link utilization. The MAC controls whether
299 the system should enter or exit the LPI mode and communicate this to PHY.
301 As soon as the interface is opened, the driver verifies if the EEE can be
302 supported. This is done by looking at both the DMA HW capability register and
303 the PHY devices MCD registers.
305 To enter in TX LPI mode the driver needs to have a software timer that enable
306 and disable the LPI mode when there is nothing to be transmitted.
308 Precision Time Protocol (PTP)
309 -----------------------------
311 The driver supports the IEEE 1588-2002, Precision Time Protocol (PTP), which
312 enables precise synchronization of clocks in measurement and control systems
313 implemented with technologies such as network communication.
315 In addition to the basic timestamp features mentioned in IEEE 1588-2002
316 Timestamps, new GMAC cores support the advanced timestamp features.
317 IEEE 1588-2008 can be enabled when configuring the Kernel.
322 New GMAC devices provide own way to manage RGMII/SGMII. This information is
323 available at run-time by looking at the HW capability register. This means
324 that the stmmac can manage auto-negotiation and link status w/o using the
325 PHYLIB stuff. In fact, the HW provides a subset of extended registers to
326 restart the ANE, verify Full/Half duplex mode and Speed. Thanks to these
327 registers, it is possible to look at the Auto-negotiated Link Parter Ability.
332 The driver is compatible with Physical Abstraction Layer to be connected with
333 PHY and GPHY devices.
338 Several information can be passed through the platform and device-tree.
342 struct plat_stmmacenet_data {
348 2) PHY Physical Address. If set to -1 the driver will pick the first PHY it
353 3) PHY Device Interface::
357 4) Specific platform fields for the MDIO bus::
359 struct stmmac_mdio_bus_data *mdio_bus_data;
361 5) Internal DMA parameters::
363 struct stmmac_dma_cfg *dma_cfg;
365 6) Fixed CSR Clock Range selection::
369 7) HW uses the GMAC core::
373 8) If set the MAC will use Enhanced Descriptors::
377 9) Core is able to perform TX Checksum and/or RX Checksum in HW::
382 11) Some HWs are not able to perform the csum in HW for over-sized frames due
383 to limited buffer sizes. Setting this flag the csum will be done in SW on
388 12) Core has the embedded power module::
392 13) Force DMA to use the Store and Forward mode or Threshold mode::
394 int force_sf_dma_mode;
395 int force_thresh_dma_mode;
397 15) Force to disable the RX Watchdog feature and switch to NAPI mode::
401 16) Limit the maximum operating speed and MTU::
406 18) Number of Multicast/Unicast filters::
408 int multicast_filter_bins;
409 int unicast_filter_entries;
411 20) Limit the maximum TX and RX FIFO size::
416 21) Use the specified number of TX and RX Queues::
418 u32 rx_queues_to_use;
419 u32 tx_queues_to_use;
421 22) Use the specified TX and RX scheduling algorithm::
423 u8 rx_sched_algorithm;
424 u8 tx_sched_algorithm;
426 23) Internal TX and RX Queue parameters::
428 struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
429 struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
431 24) This callback is used for modifying some syscfg registers (on ST SoCs)
432 according to the link speed negotiated by the physical layer::
434 void (*fix_mac_speed)(void *priv, unsigned int speed);
436 25) Callbacks used for calling a custom initialization; This is sometimes
437 necessary on some platforms (e.g. ST boxes) where the HW needs to have set
438 some PIO lines or system cfg registers. init/exit callbacks should not use
439 or modify platform data::
441 int (*init)(struct platform_device *pdev, void *priv);
442 void (*exit)(struct platform_device *pdev, void *priv);
444 26) Perform HW setup of the bus. For example, on some ST platforms this field
445 is used to configure the AMBA bridge to generate more efficient STBus traffic::
447 struct mac_device_info *(*setup)(void *priv);
450 27) Internal clocks and rates::
452 struct clk *stmmac_clk;
454 struct clk *clk_ptp_ref;
455 unsigned int clk_ptp_rate;
456 unsigned int clk_ref_rate;
461 struct reset_control *stmmac_rst;
463 29) AXI Internal Parameters::
465 struct stmmac_axi *axi;
467 30) HW uses GMAC>4 cores::
471 31) HW is sun8i based::
475 32) Enables TSO feature::
479 33) Enables Receive Side Scaling (RSS) feature::
483 34) MAC Port selection::
485 int mac_port_sel_speed;
487 35) Enables TX LPI Clock Gating::
489 bool en_tx_lpi_clockgating;
491 36) HW uses XGMAC>2.10 cores::
499 For MDIO bus data, we have:
503 struct stmmac_mdio_bus_data {
505 1) PHY mask passed when MDIO bus is registered::
507 unsigned int phy_mask;
509 2) List of IRQs, one per PHY::
513 3) If IRQs is NULL, use this for probed PHY::
517 4) Set to true if PHY needs reset::
525 For DMA engine configuration, we have:
529 struct stmmac_dma_cfg {
531 1) Programmable Burst Length (TX and RX)::
535 2) If set, DMA TX / RX will use this value rather than pbl::
544 4) Enable Fixed or Mixed burst::
549 5) Enable Address Aligned Beats::
553 6) Enable Enhanced Addressing (> 32 bits)::
561 For DMA AXI parameters, we have:
572 2) Set AXI Write / Read maximum outstanding requests::
577 3) Set AXI 4KB bursts::
581 4) Set AXI maximum burst length map::
583 u32 axi_blen[AXI_BLEN];
585 5) Set AXI Fixed burst / mixed burst::
590 6) Set AXI rebuild incrx mode::
598 For the RX Queues configuration, we have:
602 struct stmmac_rxq_cfg {
604 1) Mode to use (DCB or AVB)::
608 2) DMA channel to use::
612 3) Packet routing, if applicable::
616 4) Use priority routing, and priority to route::
625 For the TX Queues configuration, we have:
629 struct stmmac_txq_cfg {
631 1) Queue weight in scheduler::
635 2) Mode to use (DCB or AVB)::
639 3) Credit Base Shaper Parameters::
646 4) Use priority scheduling, and priority::
655 Device Tree Information
656 -----------------------
658 Please refer to the following document:
659 Documentation/devicetree/bindings/net/snps,dwmac.yaml
664 Note that, starting from new chips, where it is available the HW capability
665 register, many configurations are discovered at run-time for example to
666 understand if EEE, HW csum, PTP, enhanced descriptor etc are actually
667 available. As strategy adopted in this driver, the information from the HW
668 capability register can replace what has been passed from the platform.
673 The driver exports many information i.e. internal statistics, debug
674 information, MAC and DMA registers etc.
676 These can be read in several ways depending on the type of the information
679 For example a user can be use the ethtool support to get statistics: e.g.
680 using: ``ethtool -S ethX`` (that shows the Management counters (MMC) if
681 supported) or sees the MAC/DMA registers: e.g. using: ``ethtool -d ethX``
683 Compiling the Kernel with ``CONFIG_DEBUG_FS`` the driver will export the
684 following debugfs entries:
686 - ``descriptors_status``: To show the DMA TX/RX descriptor rings
687 - ``dma_cap``: To show the HW Capabilities
689 Developer can also use the ``debug`` module parameter to get further debug
690 information (please see: NETIF Msg Level).
695 If an issue is identified with the released source code on a supported kernel
696 with a supported adapter, email the specific information related to the
697 issue to netdev@vger.kernel.org