Update ethtool to version 6 (#3620)
[openwrt/svn-archive/archive.git] / net / ethtool / patches / 01-ixp4xx_ethtool_autotools.patch
1 --- a/Makefile.am
2 +++ b/Makefile.am
3 @@ -8,7 +8,7 @@
4 amd8111e.c de2104x.c e100.c e1000.c \
5 fec_8xx.c ibm_emac.c ixgb.c natsemi.c \
6 pcnet32.c realtek.c tg3.c marvell.c vioc.c \
7 - smsc911x.c
8 + smsc911x.c ixp4xx.c
9
10 dist-hook:
11 cp $(top_srcdir)/ethtool.spec $(distdir)
12 --- a/Makefile.in
13 +++ b/Makefile.in
14 @@ -57,7 +57,7 @@
15 fec_8xx.$(OBJEXT) ibm_emac.$(OBJEXT) ixgb.$(OBJEXT) \
16 natsemi.$(OBJEXT) pcnet32.$(OBJEXT) realtek.$(OBJEXT) \
17 tg3.$(OBJEXT) marvell.$(OBJEXT) vioc.$(OBJEXT) \
18 - smsc911x.$(OBJEXT)
19 + smsc911x.$(OBJEXT) ixp4xx.$(OBJEXT)
20 ethtool_OBJECTS = $(am_ethtool_OBJECTS)
21 ethtool_LDADD = $(LDADD)
22 DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
23 @@ -166,7 +166,7 @@
24 amd8111e.c de2104x.c e100.c e1000.c \
25 fec_8xx.c ibm_emac.c ixgb.c natsemi.c \
26 pcnet32.c realtek.c tg3.c marvell.c vioc.c \
27 - smsc911x.c
28 + smsc911x.c ixp4xx.c
29
30 all: ethtool-config.h
31 $(MAKE) $(AM_MAKEFLAGS) all-am
32 @@ -266,6 +266,7 @@
33 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fec_8xx.Po@am__quote@
34 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ibm_emac.Po@am__quote@
35 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ixgb.Po@am__quote@
36 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ixp4xx.Po@am__quote@
37 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marvell.Po@am__quote@
38 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/natsemi.Po@am__quote@
39 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcnet32.Po@am__quote@
40 --- a/ethtool-util.h
41 +++ b/ethtool-util.h
42 @@ -69,4 +69,7 @@
43 /* SMSC LAN911x/LAN921x embedded ethernet controller */
44 int smsc911x_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
45
46 +/* Intel IXP4xx internal MAC */
47 +int ixp4xx_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
48 +
49 #endif
50 --- a/ethtool.c
51 +++ b/ethtool.c
52 @@ -1015,6 +1015,7 @@
53 { "sky2", sky2_dump_regs },
54 { "vioc", vioc_dump_regs },
55 { "smsc911x", smsc911x_dump_regs },
56 + { "ixp4xx_mac", ixp4xx_dump_regs },
57 };
58
59 static int dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
60 --- a/ethtool.spec
61 +++ /dev/null
62 @@ -1,42 +0,0 @@
63 -Name : ethtool
64 -Version : 6
65 -Release : 1
66 -Group : Utilities
67 -
68 -Summary : A tool for setting ethernet parameters
69 -
70 -Copyright : GPL
71 -URL : http://sourceforge.net/projects/gkernel/
72 -
73 -Buildroot : %{_tmppath}/%{name}-%{version}
74 -Source : %{name}-%{version}.tar.gz
75 -
76 -
77 -%description
78 -Ethtool is a small utility to get and set values from your your ethernet
79 -controllers. Not all ethernet drivers support ethtool, but it is getting
80 -better. If your ethernet driver doesn't support it, ask the maintainer to
81 -write support - it's not hard!
82 -
83 -
84 -%prep
85 -%setup -q
86 -
87 -
88 -%build
89 -CFLAGS="${RPM_OPT_FLAGS}" ./configure --prefix=/usr --mandir=%{_mandir}
90 -make
91 -
92 -
93 -%install
94 -make install DESTDIR=${RPM_BUILD_ROOT}
95 -
96 -
97 -%files
98 -%defattr(-,root,root)
99 -/usr/sbin/ethtool
100 -%{_mandir}/man8/ethtool.8*
101 -%doc AUTHORS COPYING INSTALL NEWS README ChangeLog
102 -
103 -
104 -%changelog
105 --- /dev/null
106 +++ b/ixp4xx.c
107 @@ -0,0 +1,131 @@
108 +/*
109 + * Copyright (c) 2006 Christian Hohnstaed <chohnstaedt@innominate.com>
110 + * This file is released under the GPLv2
111 + */
112 +
113 +#include <stdio.h>
114 +#include "ethtool-util.h"
115 +
116 +#ifndef BIT
117 +#define BIT(x) (1<<x)
118 +#endif
119 +
120 +#define TX_CNTRL1_TX_EN BIT(0)
121 +#define TX_CNTRL1_DUPLEX BIT(1)
122 +#define TX_CNTRL1_RETRY BIT(2)
123 +#define TX_CNTRL1_PAD_EN BIT(3)
124 +#define TX_CNTRL1_FCS_EN BIT(4)
125 +#define TX_CNTRL1_2DEFER BIT(5)
126 +#define TX_CNTRL1_RMII BIT(6)
127 +
128 +/* TX Control Register 2 */
129 +#define TX_CNTRL2_RETRIES_MASK 0xf
130 +
131 +/* RX Control Register 1 */
132 +#define RX_CNTRL1_RX_EN BIT(0)
133 +#define RX_CNTRL1_PADSTRIP_EN BIT(1)
134 +#define RX_CNTRL1_CRC_EN BIT(2)
135 +#define RX_CNTRL1_PAUSE_EN BIT(3)
136 +#define RX_CNTRL1_LOOP_EN BIT(4)
137 +#define RX_CNTRL1_ADDR_FLTR_EN BIT(5)
138 +#define RX_CNTRL1_RX_RUNT_EN BIT(6)
139 +#define RX_CNTRL1_BCAST_DIS BIT(7)
140 +
141 +/* Core Control Register */
142 +#define CORE_RESET BIT(0)
143 +#define CORE_RX_FIFO_FLUSH BIT(1)
144 +#define CORE_TX_FIFO_FLUSH BIT(2)
145 +#define CORE_SEND_JAM BIT(3)
146 +#define CORE_MDC_EN BIT(4)
147 +
148 +#define MAC "%02x:%02x:%02x:%02x:%02x:%02x"
149 +#define MAC_DATA(d) (d)[0], (d)[1], (d)[2], (d)[3], (d)[4], (d)[5]
150 +
151 +int ixp4xx_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
152 +{
153 + u8 *data = regs->data;
154 +
155 + fprintf(stdout,
156 + "TXctrl: 0x%02x:0x%02x\n"
157 + " Enable: %s\n"
158 + " Duplex: %s\n"
159 + " Retry: %s (%d)\n"
160 + " Padding: %s\n"
161 + " Frame check: %s\n"
162 + " TX deferral: %s\n"
163 + " Connection: %s\n"
164 + "\n",
165 + data[0], data[1],
166 + data[0] & TX_CNTRL1_TX_EN ? "yes" : "no",
167 + data[0] & TX_CNTRL1_DUPLEX ? "half" : "full",
168 + data[0] & TX_CNTRL1_RETRY ? "enabled" : "disabled",
169 + data[1] & TX_CNTRL2_RETRIES_MASK,
170 + data[0] & TX_CNTRL1_PAD_EN ? "enabled" : "disabled",
171 + data[0] & TX_CNTRL1_FCS_EN ? "enabled" : "disabled",
172 + data[0] & TX_CNTRL1_2DEFER ? "two-part" : "one-part",
173 + data[0] & TX_CNTRL1_RMII ? "RMII" : "Full MII"
174 + );
175 +
176 + fprintf(stdout,
177 + "RXctrl: 0x%02x\n"
178 + " Enable: %s\n"
179 + " Pad strip: %s\n"
180 + " CRC check: %s\n"
181 + " Pause: %s\n"
182 + " Loop: %s\n"
183 + " Promiscous: %s\n"
184 + " Runt frames: %s\n"
185 + " Broadcast: %s\n"
186 + "\n",
187 + data[2],
188 + data[2] & RX_CNTRL1_RX_EN ? "yes" : "no",
189 + data[2] & RX_CNTRL1_PADSTRIP_EN ? "enabled" : "disabled",
190 + data[2] & RX_CNTRL1_CRC_EN ? "enabled" : "disabled",
191 + data[2] & RX_CNTRL1_PAUSE_EN ? "enabled" : "disabled",
192 + data[2] & RX_CNTRL1_LOOP_EN ? "enabled" : "disabled",
193 + data[2] & RX_CNTRL1_ADDR_FLTR_EN ? "disabled" : "enabled",
194 + data[2] & RX_CNTRL1_RX_RUNT_EN ? "forward" : "discard",
195 + data[2] & RX_CNTRL1_BCAST_DIS ? "disabled" : "enabled"
196 + );
197 + fprintf(stdout,
198 + "Core control: 0x%02x\n"
199 + " Core state: %s\n"
200 + " RX fifo: %s\n"
201 + " TX fifo: %s\n"
202 + " Send jam: %s\n"
203 + " MDC clock %s\n"
204 + "\n",
205 + data[32],
206 + data[32] & CORE_RESET ? "reset" : "normal operation",
207 + data[32] & CORE_RX_FIFO_FLUSH ? "flush" : "ok",
208 + data[32] & CORE_TX_FIFO_FLUSH ? "flush" : "ok",
209 + data[32] & CORE_SEND_JAM ? "yes" : "no",
210 + data[32] & CORE_MDC_EN ? "output" : "input"
211 + );
212 + fprintf(stdout,
213 + "MAC addresses: \n"
214 + " Multicast mask: " MAC "\n"
215 + " Multicast address: " MAC "\n"
216 + " Unicast address: " MAC "\n"
217 + "\n",
218 + MAC_DATA(data+13), MAC_DATA(data+19), MAC_DATA(data+26)
219 + );
220 + fprintf(stdout,
221 + "Random seed: 0x%02x\n"
222 + "Threshold empty: %3d\n"
223 + "Threshold full: %3d\n"
224 + "TX buffer size: %3d\n"
225 + "TX deferral: %3d\n"
226 + "RX deferral: %3d\n"
227 + "TX two deferral 1: %3d\n"
228 + "TX two deferral 2: %3d\n"
229 + "Slot time: %3d\n"
230 + "Internal clock: %3d\n"
231 + "\n",
232 + data[4], data[5], data[6], data[7], data[8], data[9],
233 + data[10], data[11], data[12], data[25]
234 + );
235 +
236 + return 0;
237 +}
238 +