stmmac.txt 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. STMicroelectronics 10/100/1000 Synopsys Ethernet driver
  2. Copyright (C) 2007-2010 STMicroelectronics Ltd
  3. Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
  4. This is the driver for the MAC 10/100/1000 on-chip Ethernet controllers
  5. (Synopsys IP blocks); it has been fully tested on STLinux platforms.
  6. Currently this network device driver is for all STM embedded MAC/GMAC
  7. (7xxx SoCs). Other platforms start using it i.e. ARM SPEAr.
  8. DWC Ether MAC 10/100/1000 Universal version 3.41a and DWC Ether MAC 10/100
  9. Universal version 4.0 have been used for developing the first code
  10. implementation.
  11. Please, for more information also visit: www.stlinux.com
  12. 1) Kernel Configuration
  13. The kernel configuration option is STMMAC_ETH:
  14. Device Drivers ---> Network device support ---> Ethernet (1000 Mbit) --->
  15. STMicroelectronics 10/100/1000 Ethernet driver (STMMAC_ETH)
  16. 2) Driver parameters list:
  17. debug: message level (0: no output, 16: all);
  18. phyaddr: to manually provide the physical address to the PHY device;
  19. dma_rxsize: DMA rx ring size;
  20. dma_txsize: DMA tx ring size;
  21. buf_sz: DMA buffer size;
  22. tc: control the HW FIFO threshold;
  23. tx_coe: Enable/Disable Tx Checksum Offload engine;
  24. watchdog: transmit timeout (in milliseconds);
  25. flow_ctrl: Flow control ability [on/off];
  26. pause: Flow Control Pause Time;
  27. tmrate: timer period (only if timer optimisation is configured).
  28. 3) Command line options
  29. Driver parameters can be also passed in command line by using:
  30. stmmaceth=dma_rxsize:128,dma_txsize:512
  31. 4) Driver information and notes
  32. 4.1) Transmit process
  33. The xmit method is invoked when the kernel needs to transmit a packet; it sets
  34. the descriptors in the ring and informs the DMA engine that there is a packet
  35. ready to be transmitted.
  36. Once the controller has finished transmitting the packet, an interrupt is
  37. triggered; So the driver will be able to release the socket buffers.
  38. By default, the driver sets the NETIF_F_SG bit in the features field of the
  39. net_device structure enabling the scatter/gather feature.
  40. 4.2) Receive process
  41. When one or more packets are received, an interrupt happens. The interrupts
  42. are not queued so the driver has to scan all the descriptors in the ring during
  43. the receive process.
  44. This is based on NAPI so the interrupt handler signals only if there is work to be
  45. done, and it exits.
  46. Then the poll method will be scheduled at some future point.
  47. The incoming packets are stored, by the DMA, in a list of pre-allocated socket
  48. buffers in order to avoid the memcpy (Zero-copy).
  49. 4.3) Timer-Driver Interrupt
  50. Instead of having the device that asynchronously notifies the frame receptions, the
  51. driver configures a timer to generate an interrupt at regular intervals.
  52. Based on the granularity of the timer, the frames that are received by the device
  53. will experience different levels of latency. Some NICs have dedicated timer
  54. device to perform this task. STMMAC can use either the RTC device or the TMU
  55. channel 2 on STLinux platforms.
  56. The timers frequency can be passed to the driver as parameter; when change it,
  57. take care of both hardware capability and network stability/performance impact.
  58. Several performance tests on STM platforms showed this optimisation allows to spare
  59. the CPU while having the maximum throughput.
  60. 4.4) WOL
  61. Wake up on Lan feature through Magic Frame is only supported for the GMAC
  62. core.
  63. 4.5) DMA descriptors
  64. Driver handles both normal and enhanced descriptors. The latter has been only
  65. tested on DWC Ether MAC 10/100/1000 Universal version 3.41a.
  66. 4.6) Ethtool support
  67. Ethtool is supported. Driver statistics and internal errors can be taken using:
  68. ethtool -S ethX command. It is possible to dump registers etc.
  69. 4.7) Jumbo and Segmentation Offloading
  70. Jumbo frames are supported and tested for the GMAC.
  71. The GSO has been also added but it's performed in software.
  72. LRO is not supported.
  73. 4.8) Physical
  74. The driver is compatible with PAL to work with PHY and GPHY devices.
  75. 4.9) Platform information
  76. Several information came from the platform; please refer to the
  77. driver's Header file in include/linux directory.
  78. struct plat_stmmacenet_data {
  79. int bus_id;
  80. int pbl;
  81. int clk_csr;
  82. int has_gmac;
  83. int enh_desc;
  84. int tx_coe;
  85. int bugged_jumbo;
  86. int pmt;
  87. void (*fix_mac_speed)(void *priv, unsigned int speed);
  88. void (*bus_setup)(unsigned long ioaddr);
  89. #ifdef CONFIG_STM_DRIVERS
  90. struct stm_pad_config *pad_config;
  91. #endif
  92. void *bsp_priv;
  93. };
  94. Where:
  95. - pbl (Programmable Burst Length) is maximum number of
  96. beats to be transferred in one DMA transaction.
  97. GMAC also enables the 4xPBL by default.
  98. - fix_mac_speed and bus_setup are used to configure internal target
  99. registers (on STM platforms);
  100. - has_gmac: GMAC core is on board (get it at run-time in the next step);
  101. - bus_id: bus identifier.
  102. - tx_coe: core is able to perform the tx csum in HW.
  103. - enh_desc: if sets the MAC will use the enhanced descriptor structure.
  104. - clk_csr: CSR Clock range selection.
  105. - bugged_jumbo: some HWs are not able to perform the csum in HW for
  106. over-sized frames due to limited buffer sizes. Setting this
  107. flag the csum will be done in SW on JUMBO frames.
  108. struct plat_stmmacphy_data {
  109. int bus_id;
  110. int phy_addr;
  111. unsigned int phy_mask;
  112. int interface;
  113. int (*phy_reset)(void *priv);
  114. void *priv;
  115. };
  116. Where:
  117. - bus_id: bus identifier;
  118. - phy_addr: physical address used for the attached phy device;
  119. set it to -1 to get it at run-time;
  120. - interface: physical MII interface mode;
  121. - phy_reset: hook to reset HW function.
  122. SOURCES:
  123. - Kconfig
  124. - Makefile
  125. - stmmac_main.c: main network device driver;
  126. - stmmac_mdio.c: mdio functions;
  127. - stmmac_ethtool.c: ethtool support;
  128. - stmmac_timer.[ch]: timer code used for mitigating the driver dma interrupts
  129. Only tested on ST40 platforms based.
  130. - stmmac.h: private driver structure;
  131. - common.h: common definitions and VFTs;
  132. - descs.h: descriptor structure definitions;
  133. - dwmac1000_core.c: GMAC core functions;
  134. - dwmac1000_dma.c: dma functions for the GMAC chip;
  135. - dwmac1000.h: specific header file for the GMAC;
  136. - dwmac100_core: MAC 100 core and dma code;
  137. - dwmac100_dma.c: dma funtions for the MAC chip;
  138. - dwmac1000.h: specific header file for the MAC;
  139. - dwmac_lib.c: generic DMA functions shared among chips
  140. - enh_desc.c: functions for handling enhanced descriptors
  141. - norm_desc.c: functions for handling normal descriptors
  142. TODO:
  143. - XGMAC controller is not supported.
  144. - Review the timer optimisation code to use an embedded device that seems to be
  145. available in new chip generations.