You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
5.1 KiB

  1. --- a/Makefile.am
  2. +++ b/Makefile.am
  3. @@ -13,7 +13,7 @@ ethtool_SOURCES += \
  4. fec_8xx.c ibm_emac.c ixgb.c ixgbe.c natsemi.c \
  5. pcnet32.c realtek.c tg3.c marvell.c vioc.c \
  6. smsc911x.c at76c50x-usb.c sfc.c stmmac.c \
  7. - sfpid.c sfpdiag.c ixgbevf.c
  8. + sfpid.c sfpdiag.c ixgbevf.c ixp4xx.c
  9. endif
  10. TESTS = test-cmdline test-features
  11. --- a/ethtool.c
  12. +++ b/ethtool.c
  13. @@ -894,6 +894,7 @@ static const struct {
  14. { "ixgb", ixgb_dump_regs },
  15. { "ixgbe", ixgbe_dump_regs },
  16. { "ixgbevf", ixgbevf_dump_regs },
  17. + { "ixp4xx", ixp4xx_dump_regs },
  18. { "natsemi", natsemi_dump_regs },
  19. { "e100", e100_dump_regs },
  20. { "amd8111e", amd8111e_dump_regs },
  21. --- a/internal.h
  22. +++ b/internal.h
  23. @@ -243,6 +243,9 @@ int st_gmac_dump_regs(struct ethtool_drv
  24. /* Et131x ethernet controller */
  25. int et131x_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
  26. +/* Intel IXP4xx internal MAC */
  27. +int ixp4xx_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
  28. +
  29. /* Rx flow classification */
  30. int rxclass_parse_ruleopts(struct cmd_context *ctx,
  31. struct ethtool_rx_flow_spec *fsp);
  32. --- /dev/null
  33. +++ b/ixp4xx.c
  34. @@ -0,0 +1,130 @@
  35. +/*
  36. + * Copyright (c) 2006 Christian Hohnstaed <chohnstaedt@innominate.com>
  37. + * This file is released under the GPLv2
  38. + */
  39. +
  40. +#include <stdio.h>
  41. +#include "internal.h"
  42. +
  43. +#ifndef BIT
  44. +#define BIT(x) (1<<x)
  45. +#endif
  46. +
  47. +#define TX_CNTRL1_TX_EN BIT(0)
  48. +#define TX_CNTRL1_DUPLEX BIT(1)
  49. +#define TX_CNTRL1_RETRY BIT(2)
  50. +#define TX_CNTRL1_PAD_EN BIT(3)
  51. +#define TX_CNTRL1_FCS_EN BIT(4)
  52. +#define TX_CNTRL1_2DEFER BIT(5)
  53. +#define TX_CNTRL1_RMII BIT(6)
  54. +
  55. +/* TX Control Register 2 */
  56. +#define TX_CNTRL2_RETRIES_MASK 0xf
  57. +
  58. +/* RX Control Register 1 */
  59. +#define RX_CNTRL1_RX_EN BIT(0)
  60. +#define RX_CNTRL1_PADSTRIP_EN BIT(1)
  61. +#define RX_CNTRL1_CRC_EN BIT(2)
  62. +#define RX_CNTRL1_PAUSE_EN BIT(3)
  63. +#define RX_CNTRL1_LOOP_EN BIT(4)
  64. +#define RX_CNTRL1_ADDR_FLTR_EN BIT(5)
  65. +#define RX_CNTRL1_RX_RUNT_EN BIT(6)
  66. +#define RX_CNTRL1_BCAST_DIS BIT(7)
  67. +
  68. +/* Core Control Register */
  69. +#define CORE_RESET BIT(0)
  70. +#define CORE_RX_FIFO_FLUSH BIT(1)
  71. +#define CORE_TX_FIFO_FLUSH BIT(2)
  72. +#define CORE_SEND_JAM BIT(3)
  73. +#define CORE_MDC_EN BIT(4)
  74. +
  75. +#define MAC "%02x:%02x:%02x:%02x:%02x:%02x"
  76. +#define MAC_DATA(d) (d)[0], (d)[1], (d)[2], (d)[3], (d)[4], (d)[5]
  77. +
  78. +int ixp4xx_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
  79. +{
  80. + u8 *data = regs->data;
  81. +
  82. + fprintf(stdout,
  83. + "TXctrl: 0x%02x:0x%02x\n"
  84. + " Enable: %s\n"
  85. + " Duplex: %s\n"
  86. + " Retry: %s (%d)\n"
  87. + " Padding: %s\n"
  88. + " Frame check: %s\n"
  89. + " TX deferral: %s\n"
  90. + " Connection: %s\n"
  91. + "\n",
  92. + data[0], data[1],
  93. + data[0] & TX_CNTRL1_TX_EN ? "yes" : "no",
  94. + data[0] & TX_CNTRL1_DUPLEX ? "half" : "full",
  95. + data[0] & TX_CNTRL1_RETRY ? "enabled" : "disabled",
  96. + data[1] & TX_CNTRL2_RETRIES_MASK,
  97. + data[0] & TX_CNTRL1_PAD_EN ? "enabled" : "disabled",
  98. + data[0] & TX_CNTRL1_FCS_EN ? "enabled" : "disabled",
  99. + data[0] & TX_CNTRL1_2DEFER ? "two-part" : "one-part",
  100. + data[0] & TX_CNTRL1_RMII ? "RMII" : "Full MII"
  101. + );
  102. +
  103. + fprintf(stdout,
  104. + "RXctrl: 0x%02x\n"
  105. + " Enable: %s\n"
  106. + " Pad strip: %s\n"
  107. + " CRC check: %s\n"
  108. + " Pause: %s\n"
  109. + " Loop: %s\n"
  110. + " Promiscous: %s\n"
  111. + " Runt frames: %s\n"
  112. + " Broadcast: %s\n"
  113. + "\n",
  114. + data[2],
  115. + data[2] & RX_CNTRL1_RX_EN ? "yes" : "no",
  116. + data[2] & RX_CNTRL1_PADSTRIP_EN ? "enabled" : "disabled",
  117. + data[2] & RX_CNTRL1_CRC_EN ? "enabled" : "disabled",
  118. + data[2] & RX_CNTRL1_PAUSE_EN ? "enabled" : "disabled",
  119. + data[2] & RX_CNTRL1_LOOP_EN ? "enabled" : "disabled",
  120. + data[2] & RX_CNTRL1_ADDR_FLTR_EN ? "disabled" : "enabled",
  121. + data[2] & RX_CNTRL1_RX_RUNT_EN ? "forward" : "discard",
  122. + data[2] & RX_CNTRL1_BCAST_DIS ? "disabled" : "enabled"
  123. + );
  124. + fprintf(stdout,
  125. + "Core control: 0x%02x\n"
  126. + " Core state: %s\n"
  127. + " RX fifo: %s\n"
  128. + " TX fifo: %s\n"
  129. + " Send jam: %s\n"
  130. + " MDC clock %s\n"
  131. + "\n",
  132. + data[32],
  133. + data[32] & CORE_RESET ? "reset" : "normal operation",
  134. + data[32] & CORE_RX_FIFO_FLUSH ? "flush" : "ok",
  135. + data[32] & CORE_TX_FIFO_FLUSH ? "flush" : "ok",
  136. + data[32] & CORE_SEND_JAM ? "yes" : "no",
  137. + data[32] & CORE_MDC_EN ? "output" : "input"
  138. + );
  139. + fprintf(stdout,
  140. + "MAC addresses: \n"
  141. + " Multicast mask: " MAC "\n"
  142. + " Multicast address: " MAC "\n"
  143. + " Unicast address: " MAC "\n"
  144. + "\n",
  145. + MAC_DATA(data+13), MAC_DATA(data+19), MAC_DATA(data+26)
  146. + );
  147. + fprintf(stdout,
  148. + "Random seed: 0x%02x\n"
  149. + "Threshold empty: %3d\n"
  150. + "Threshold full: %3d\n"
  151. + "TX buffer size: %3d\n"
  152. + "TX deferral: %3d\n"
  153. + "RX deferral: %3d\n"
  154. + "TX two deferral 1: %3d\n"
  155. + "TX two deferral 2: %3d\n"
  156. + "Slot time: %3d\n"
  157. + "Internal clock: %3d\n"
  158. + "\n",
  159. + data[4], data[5], data[6], data[7], data[8], data[9],
  160. + data[10], data[11], data[12], data[25]
  161. + );
  162. +
  163. + return 0;
  164. +}