0001 .. SPDX-License-Identifier: GPL-2.0+
0002
0003 ==============================================================
0004 Linux Driver for the Synopsys(R) Ethernet Controllers "stmmac"
0005 ==============================================================
0006
0007 Authors: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
0008 Alexandre Torgue <alexandre.torgue@st.com>, Jose Abreu <joabreu@synopsys.com>
0009
0010 Contents
0011 ========
0012
0013 - In This Release
0014 - Feature List
0015 - Kernel Configuration
0016 - Command Line Parameters
0017 - Driver Information and Notes
0018 - Debug Information
0019 - Support
0020
0021 In This Release
0022 ===============
0023
0024 This file describes the stmmac Linux Driver for all the Synopsys(R) Ethernet
0025 Controllers.
0026
0027 Currently, this network device driver is for all STi embedded MAC/GMAC
0028 (i.e. 7xxx/5xxx SoCs), SPEAr (arm), Loongson1B (mips) and XILINX XC2V3000
0029 FF1152AMT0221 D1215994A VIRTEX FPGA board. The Synopsys Ethernet QoS 5.0 IPK
0030 is also supported.
0031
0032 DesignWare(R) Cores Ethernet MAC 10/100/1000 Universal version 3.70a
0033 (and older) and DesignWare(R) Cores Ethernet Quality-of-Service version 4.0
0034 (and upper) have been used for developing this driver as well as
0035 DesignWare(R) Cores XGMAC - 10G Ethernet MAC and DesignWare(R) Cores
0036 Enterprise MAC - 100G Ethernet MAC.
0037
0038 This driver supports both the platform bus and PCI.
0039
0040 This driver includes support for the following Synopsys(R) DesignWare(R)
0041 Cores Ethernet Controllers and corresponding minimum and maximum versions:
0042
0043 +-------------------------------+--------------+--------------+--------------+
0044 | Controller Name | Min. Version | Max. Version | Abbrev. Name |
0045 +===============================+==============+==============+==============+
0046 | Ethernet MAC Universal | N/A | 3.73a | GMAC |
0047 +-------------------------------+--------------+--------------+--------------+
0048 | Ethernet Quality-of-Service | 4.00a | N/A | GMAC4+ |
0049 +-------------------------------+--------------+--------------+--------------+
0050 | XGMAC - 10G Ethernet MAC | 2.10a | N/A | XGMAC2+ |
0051 +-------------------------------+--------------+--------------+--------------+
0052 | XLGMAC - 100G Ethernet MAC | 2.00a | N/A | XLGMAC2+ |
0053 +-------------------------------+--------------+--------------+--------------+
0054
0055 For questions related to hardware requirements, refer to the documentation
0056 supplied with your Ethernet adapter. All hardware requirements listed apply
0057 to use with Linux.
0058
0059 Feature List
0060 ============
0061
0062 The following features are available in this driver:
0063 - GMII/MII/RGMII/SGMII/RMII/XGMII/XLGMII Interface
0064 - Half-Duplex / Full-Duplex Operation
0065 - Energy Efficient Ethernet (EEE)
0066 - IEEE 802.3x PAUSE Packets (Flow Control)
0067 - RMON/MIB Counters
0068 - IEEE 1588 Timestamping (PTP)
0069 - Pulse-Per-Second Output (PPS)
0070 - MDIO Clause 22 / Clause 45 Interface
0071 - MAC Loopback
0072 - ARP Offloading
0073 - Automatic CRC / PAD Insertion and Checking
0074 - Checksum Offload for Received and Transmitted Packets
0075 - Standard or Jumbo Ethernet Packets
0076 - Source Address Insertion / Replacement
0077 - VLAN TAG Insertion / Replacement / Deletion / Filtering (HASH and PERFECT)
0078 - Programmable TX and RX Watchdog and Coalesce Settings
0079 - Destination Address Filtering (PERFECT)
0080 - HASH Filtering (Multicast)
0081 - Layer 3 / Layer 4 Filtering
0082 - Remote Wake-Up Detection
0083 - Receive Side Scaling (RSS)
0084 - Frame Preemption for TX and RX
0085 - Programmable Burst Length, Threshold, Queue Size
0086 - Multiple Queues (up to 8)
0087 - Multiple Scheduling Algorithms (TX: WRR, DWRR, WFQ, SP, CBS, EST, TBS;
0088 RX: WRR, SP)
0089 - Flexible RX Parser
0090 - TCP / UDP Segmentation Offload (TSO, USO)
0091 - Split Header (SPH)
0092 - Safety Features (ECC Protection, Data Parity Protection)
0093 - Selftests using Ethtool
0094
0095 Kernel Configuration
0096 ====================
0097
0098 The kernel configuration option is ``CONFIG_STMMAC_ETH``:
0099 - ``CONFIG_STMMAC_PLATFORM``: is to enable the platform driver.
0100 - ``CONFIG_STMMAC_PCI``: is to enable the pci driver.
0101
0102 Command Line Parameters
0103 =======================
0104
0105 If the driver is built as a module the following optional parameters are used
0106 by entering them on the command line with the modprobe command using this
0107 syntax (e.g. for PCI module)::
0108
0109 modprobe stmmac_pci [<option>=<VAL1>,<VAL2>,...]
0110
0111 Driver parameters can be also passed in command line by using::
0112
0113 stmmaceth=watchdog:100,chain_mode=1
0114
0115 The default value for each parameter is generally the recommended setting,
0116 unless otherwise noted.
0117
0118 watchdog
0119 --------
0120 :Valid Range: 5000-None
0121 :Default Value: 5000
0122
0123 This parameter overrides the transmit timeout in milliseconds.
0124
0125 debug
0126 -----
0127 :Valid Range: 0-16 (0=none,...,16=all)
0128 :Default Value: 0
0129
0130 This parameter adjusts the level of debug messages displayed in the system
0131 logs.
0132
0133 phyaddr
0134 -------
0135 :Valid Range: 0-31
0136 :Default Value: -1
0137
0138 This parameter overrides the physical address of the PHY device.
0139
0140 flow_ctrl
0141 ---------
0142 :Valid Range: 0-3 (0=off,1=rx,2=tx,3=rx/tx)
0143 :Default Value: 3
0144
0145 This parameter changes the default Flow Control ability.
0146
0147 pause
0148 -----
0149 :Valid Range: 0-65535
0150 :Default Value: 65535
0151
0152 This parameter changes the default Flow Control Pause time.
0153
0154 tc
0155 --
0156 :Valid Range: 64-256
0157 :Default Value: 64
0158
0159 This parameter changes the default HW FIFO Threshold control value.
0160
0161 buf_sz
0162 ------
0163 :Valid Range: 1536-16384
0164 :Default Value: 1536
0165
0166 This parameter changes the default RX DMA packet buffer size.
0167
0168 eee_timer
0169 ---------
0170 :Valid Range: 0-None
0171 :Default Value: 1000
0172
0173 This parameter changes the default LPI TX Expiration time in milliseconds.
0174
0175 chain_mode
0176 ----------
0177 :Valid Range: 0-1 (0=off,1=on)
0178 :Default Value: 0
0179
0180 This parameter changes the default mode of operation from Ring Mode to
0181 Chain Mode.
0182
0183 Driver Information and Notes
0184 ============================
0185
0186 Transmit Process
0187 ----------------
0188
0189 The xmit method is invoked when the kernel needs to transmit a packet; it sets
0190 the descriptors in the ring and informs the DMA engine that there is a packet
0191 ready to be transmitted.
0192
0193 By default, the driver sets the ``NETIF_F_SG`` bit in the features field of
0194 the ``net_device`` structure, enabling the scatter-gather feature. This is
0195 true on chips and configurations where the checksum can be done in hardware.
0196
0197 Once the controller has finished transmitting the packet, timer will be
0198 scheduled to release the transmit resources.
0199
0200 Receive Process
0201 ---------------
0202
0203 When one or more packets are received, an interrupt happens. The interrupts
0204 are not queued, so the driver has to scan all the descriptors in the ring
0205 during the receive process.
0206
0207 This is based on NAPI, so the interrupt handler signals only if there is work
0208 to be done, and it exits. Then the poll method will be scheduled at some
0209 future point.
0210
0211 The incoming packets are stored, by the DMA, in a list of pre-allocated socket
0212 buffers in order to avoid the memcpy (zero-copy).
0213
0214 Interrupt Mitigation
0215 --------------------
0216
0217 The driver is able to mitigate the number of its DMA interrupts using NAPI for
0218 the reception on chips older than the 3.50. New chips have an HW RX Watchdog
0219 used for this mitigation.
0220
0221 Mitigation parameters can be tuned by ethtool.
0222
0223 WoL
0224 ---
0225
0226 Wake up on Lan feature through Magic and Unicast frames are supported for the
0227 GMAC, GMAC4/5 and XGMAC core.
0228
0229 DMA Descriptors
0230 ---------------
0231
0232 Driver handles both normal and alternate descriptors. The latter has been only
0233 tested on DesignWare(R) Cores Ethernet MAC Universal version 3.41a and later.
0234
0235 stmmac supports DMA descriptor to operate both in dual buffer (RING) and
0236 linked-list(CHAINED) mode. In RING each descriptor points to two data buffer
0237 pointers whereas in CHAINED mode they point to only one data buffer pointer.
0238 RING mode is the default.
0239
0240 In CHAINED mode each descriptor will have pointer to next descriptor in the
0241 list, hence creating the explicit chaining in the descriptor itself, whereas
0242 such explicit chaining is not possible in RING mode.
0243
0244 Extended Descriptors
0245 --------------------
0246
0247 The extended descriptors give us information about the Ethernet payload when
0248 it is carrying PTP packets or TCP/UDP/ICMP over IP. These are not available on
0249 GMAC Synopsys(R) chips older than the 3.50. At probe time the driver will
0250 decide if these can be actually used. This support also is mandatory for PTPv2
0251 because the extra descriptors are used for saving the hardware timestamps and
0252 Extended Status.
0253
0254 Ethtool Support
0255 ---------------
0256
0257 Ethtool is supported. For example, driver statistics (including RMON),
0258 internal errors can be taken using::
0259
0260 ethtool -S ethX
0261
0262 Ethtool selftests are also supported. This allows to do some early sanity
0263 checks to the HW using MAC and PHY loopback mechanisms::
0264
0265 ethtool -t ethX
0266
0267 Jumbo and Segmentation Offloading
0268 ---------------------------------
0269
0270 Jumbo frames are supported and tested for the GMAC. The GSO has been also
0271 added but it's performed in software. LRO is not supported.
0272
0273 TSO Support
0274 -----------
0275
0276 TSO (TCP Segmentation Offload) feature is supported by GMAC > 4.x and XGMAC
0277 chip family. When a packet is sent through TCP protocol, the TCP stack ensures
0278 that the SKB provided to the low level driver (stmmac in our case) matches
0279 with the maximum frame len (IP header + TCP header + payload <= 1500 bytes
0280 (for MTU set to 1500)). It means that if an application using TCP want to send
0281 a packet which will have a length (after adding headers) > 1514 the packet
0282 will be split in several TCP packets: The data payload is split and headers
0283 (TCP/IP ..) are added. It is done by software.
0284
0285 When TSO is enabled, the TCP stack doesn't care about the maximum frame length
0286 and provide SKB packet to stmmac as it is. The GMAC IP will have to perform
0287 the segmentation by it self to match with maximum frame length.
0288
0289 This feature can be enabled in device tree through ``snps,tso`` entry.
0290
0291 Energy Efficient Ethernet
0292 -------------------------
0293
0294 Energy Efficient Ethernet (EEE) enables IEEE 802.3 MAC sublayer along with a
0295 family of Physical layer to operate in the Low Power Idle (LPI) mode. The EEE
0296 mode supports the IEEE 802.3 MAC operation at 100Mbps, 1000Mbps and 1Gbps.
0297
0298 The LPI mode allows power saving by switching off parts of the communication
0299 device functionality when there is no data to be transmitted & received.
0300 The system on both the side of the link can disable some functionalities and
0301 save power during the period of low-link utilization. The MAC controls whether
0302 the system should enter or exit the LPI mode and communicate this to PHY.
0303
0304 As soon as the interface is opened, the driver verifies if the EEE can be
0305 supported. This is done by looking at both the DMA HW capability register and
0306 the PHY devices MCD registers.
0307
0308 To enter in TX LPI mode the driver needs to have a software timer that enable
0309 and disable the LPI mode when there is nothing to be transmitted.
0310
0311 Precision Time Protocol (PTP)
0312 -----------------------------
0313
0314 The driver supports the IEEE 1588-2002, Precision Time Protocol (PTP), which
0315 enables precise synchronization of clocks in measurement and control systems
0316 implemented with technologies such as network communication.
0317
0318 In addition to the basic timestamp features mentioned in IEEE 1588-2002
0319 Timestamps, new GMAC cores support the advanced timestamp features.
0320 IEEE 1588-2008 can be enabled when configuring the Kernel.
0321
0322 SGMII/RGMII Support
0323 -------------------
0324
0325 New GMAC devices provide own way to manage RGMII/SGMII. This information is
0326 available at run-time by looking at the HW capability register. This means
0327 that the stmmac can manage auto-negotiation and link status w/o using the
0328 PHYLIB stuff. In fact, the HW provides a subset of extended registers to
0329 restart the ANE, verify Full/Half duplex mode and Speed. Thanks to these
0330 registers, it is possible to look at the Auto-negotiated Link Parter Ability.
0331
0332 Physical
0333 --------
0334
0335 The driver is compatible with Physical Abstraction Layer to be connected with
0336 PHY and GPHY devices.
0337
0338 Platform Information
0339 --------------------
0340
0341 Several information can be passed through the platform and device-tree.
0342
0343 ::
0344
0345 struct plat_stmmacenet_data {
0346
0347 1) Bus identifier::
0348
0349 int bus_id;
0350
0351 2) PHY Physical Address. If set to -1 the driver will pick the first PHY it
0352 finds::
0353
0354 int phy_addr;
0355
0356 3) PHY Device Interface::
0357
0358 int interface;
0359
0360 4) Specific platform fields for the MDIO bus::
0361
0362 struct stmmac_mdio_bus_data *mdio_bus_data;
0363
0364 5) Internal DMA parameters::
0365
0366 struct stmmac_dma_cfg *dma_cfg;
0367
0368 6) Fixed CSR Clock Range selection::
0369
0370 int clk_csr;
0371
0372 7) HW uses the GMAC core::
0373
0374 int has_gmac;
0375
0376 8) If set the MAC will use Enhanced Descriptors::
0377
0378 int enh_desc;
0379
0380 9) Core is able to perform TX Checksum and/or RX Checksum in HW::
0381
0382 int tx_coe;
0383 int rx_coe;
0384
0385 11) Some HWs are not able to perform the csum in HW for over-sized frames due
0386 to limited buffer sizes. Setting this flag the csum will be done in SW on
0387 JUMBO frames::
0388
0389 int bugged_jumbo;
0390
0391 12) Core has the embedded power module::
0392
0393 int pmt;
0394
0395 13) Force DMA to use the Store and Forward mode or Threshold mode::
0396
0397 int force_sf_dma_mode;
0398 int force_thresh_dma_mode;
0399
0400 15) Force to disable the RX Watchdog feature and switch to NAPI mode::
0401
0402 int riwt_off;
0403
0404 16) Limit the maximum operating speed and MTU::
0405
0406 int max_speed;
0407 int maxmtu;
0408
0409 18) Number of Multicast/Unicast filters::
0410
0411 int multicast_filter_bins;
0412 int unicast_filter_entries;
0413
0414 20) Limit the maximum TX and RX FIFO size::
0415
0416 int tx_fifo_size;
0417 int rx_fifo_size;
0418
0419 21) Use the specified number of TX and RX Queues::
0420
0421 u32 rx_queues_to_use;
0422 u32 tx_queues_to_use;
0423
0424 22) Use the specified TX and RX scheduling algorithm::
0425
0426 u8 rx_sched_algorithm;
0427 u8 tx_sched_algorithm;
0428
0429 23) Internal TX and RX Queue parameters::
0430
0431 struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
0432 struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
0433
0434 24) This callback is used for modifying some syscfg registers (on ST SoCs)
0435 according to the link speed negotiated by the physical layer::
0436
0437 void (*fix_mac_speed)(void *priv, unsigned int speed);
0438
0439 25) Callbacks used for calling a custom initialization; This is sometimes
0440 necessary on some platforms (e.g. ST boxes) where the HW needs to have set
0441 some PIO lines or system cfg registers. init/exit callbacks should not use
0442 or modify platform data::
0443
0444 int (*init)(struct platform_device *pdev, void *priv);
0445 void (*exit)(struct platform_device *pdev, void *priv);
0446
0447 26) Perform HW setup of the bus. For example, on some ST platforms this field
0448 is used to configure the AMBA bridge to generate more efficient STBus traffic::
0449
0450 struct mac_device_info *(*setup)(void *priv);
0451 void *bsp_priv;
0452
0453 27) Internal clocks and rates::
0454
0455 struct clk *stmmac_clk;
0456 struct clk *pclk;
0457 struct clk *clk_ptp_ref;
0458 unsigned int clk_ptp_rate;
0459 unsigned int clk_ref_rate;
0460 s32 ptp_max_adj;
0461
0462 28) Main reset::
0463
0464 struct reset_control *stmmac_rst;
0465
0466 29) AXI Internal Parameters::
0467
0468 struct stmmac_axi *axi;
0469
0470 30) HW uses GMAC>4 cores::
0471
0472 int has_gmac4;
0473
0474 31) HW is sun8i based::
0475
0476 bool has_sun8i;
0477
0478 32) Enables TSO feature::
0479
0480 bool tso_en;
0481
0482 33) Enables Receive Side Scaling (RSS) feature::
0483
0484 int rss_en;
0485
0486 34) MAC Port selection::
0487
0488 int mac_port_sel_speed;
0489
0490 35) Enables TX LPI Clock Gating::
0491
0492 bool en_tx_lpi_clockgating;
0493
0494 36) HW uses XGMAC>2.10 cores::
0495
0496 int has_xgmac;
0497
0498 ::
0499
0500 }
0501
0502 For MDIO bus data, we have:
0503
0504 ::
0505
0506 struct stmmac_mdio_bus_data {
0507
0508 1) PHY mask passed when MDIO bus is registered::
0509
0510 unsigned int phy_mask;
0511
0512 2) List of IRQs, one per PHY::
0513
0514 int *irqs;
0515
0516 3) If IRQs is NULL, use this for probed PHY::
0517
0518 int probed_phy_irq;
0519
0520 4) Set to true if PHY needs reset::
0521
0522 bool needs_reset;
0523
0524 ::
0525
0526 }
0527
0528 For DMA engine configuration, we have:
0529
0530 ::
0531
0532 struct stmmac_dma_cfg {
0533
0534 1) Programmable Burst Length (TX and RX)::
0535
0536 int pbl;
0537
0538 2) If set, DMA TX / RX will use this value rather than pbl::
0539
0540 int txpbl;
0541 int rxpbl;
0542
0543 3) Enable 8xPBL::
0544
0545 bool pblx8;
0546
0547 4) Enable Fixed or Mixed burst::
0548
0549 int fixed_burst;
0550 int mixed_burst;
0551
0552 5) Enable Address Aligned Beats::
0553
0554 bool aal;
0555
0556 6) Enable Enhanced Addressing (> 32 bits)::
0557
0558 bool eame;
0559
0560 ::
0561
0562 }
0563
0564 For DMA AXI parameters, we have:
0565
0566 ::
0567
0568 struct stmmac_axi {
0569
0570 1) Enable AXI LPI::
0571
0572 bool axi_lpi_en;
0573 bool axi_xit_frm;
0574
0575 2) Set AXI Write / Read maximum outstanding requests::
0576
0577 u32 axi_wr_osr_lmt;
0578 u32 axi_rd_osr_lmt;
0579
0580 3) Set AXI 4KB bursts::
0581
0582 bool axi_kbbe;
0583
0584 4) Set AXI maximum burst length map::
0585
0586 u32 axi_blen[AXI_BLEN];
0587
0588 5) Set AXI Fixed burst / mixed burst::
0589
0590 bool axi_fb;
0591 bool axi_mb;
0592
0593 6) Set AXI rebuild incrx mode::
0594
0595 bool axi_rb;
0596
0597 ::
0598
0599 }
0600
0601 For the RX Queues configuration, we have:
0602
0603 ::
0604
0605 struct stmmac_rxq_cfg {
0606
0607 1) Mode to use (DCB or AVB)::
0608
0609 u8 mode_to_use;
0610
0611 2) DMA channel to use::
0612
0613 u32 chan;
0614
0615 3) Packet routing, if applicable::
0616
0617 u8 pkt_route;
0618
0619 4) Use priority routing, and priority to route::
0620
0621 bool use_prio;
0622 u32 prio;
0623
0624 ::
0625
0626 }
0627
0628 For the TX Queues configuration, we have:
0629
0630 ::
0631
0632 struct stmmac_txq_cfg {
0633
0634 1) Queue weight in scheduler::
0635
0636 u32 weight;
0637
0638 2) Mode to use (DCB or AVB)::
0639
0640 u8 mode_to_use;
0641
0642 3) Credit Base Shaper Parameters::
0643
0644 u32 send_slope;
0645 u32 idle_slope;
0646 u32 high_credit;
0647 u32 low_credit;
0648
0649 4) Use priority scheduling, and priority::
0650
0651 bool use_prio;
0652 u32 prio;
0653
0654 ::
0655
0656 }
0657
0658 Device Tree Information
0659 -----------------------
0660
0661 Please refer to the following document:
0662 Documentation/devicetree/bindings/net/snps,dwmac.yaml
0663
0664 HW Capabilities
0665 ---------------
0666
0667 Note that, starting from new chips, where it is available the HW capability
0668 register, many configurations are discovered at run-time for example to
0669 understand if EEE, HW csum, PTP, enhanced descriptor etc are actually
0670 available. As strategy adopted in this driver, the information from the HW
0671 capability register can replace what has been passed from the platform.
0672
0673 Debug Information
0674 =================
0675
0676 The driver exports many information i.e. internal statistics, debug
0677 information, MAC and DMA registers etc.
0678
0679 These can be read in several ways depending on the type of the information
0680 actually needed.
0681
0682 For example a user can be use the ethtool support to get statistics: e.g.
0683 using: ``ethtool -S ethX`` (that shows the Management counters (MMC) if
0684 supported) or sees the MAC/DMA registers: e.g. using: ``ethtool -d ethX``
0685
0686 Compiling the Kernel with ``CONFIG_DEBUG_FS`` the driver will export the
0687 following debugfs entries:
0688
0689 - ``descriptors_status``: To show the DMA TX/RX descriptor rings
0690 - ``dma_cap``: To show the HW Capabilities
0691
0692 Developer can also use the ``debug`` module parameter to get further debug
0693 information (please see: NETIF Msg Level).
0694
0695 Support
0696 =======
0697
0698 If an issue is identified with the released source code on a supported kernel
0699 with a supported adapter, email the specific information related to the
0700 issue to netdev@vger.kernel.org