dec21140A ethernet driver for virtualpc, contributed by nicolas tittley.
[minix.git] / drivers / fxp / mii.c
blob39d65641f99730ad13983079a723cbc783f3d8c9
1 /*
2 ibm/mii.c
4 Created: Nov 2004 by Philip Homburg <philip@f-mnx.phicoh.com>
6 Media Independent (Ethernet) Interface functions
7 */
9 #include "../drivers.h"
10 #if __minix_vmd
11 #include "config.h"
12 #endif
14 #include "mii.h"
16 /*===========================================================================*
17 * mii_print_stat_speed *
18 *===========================================================================*/
19 PUBLIC void mii_print_stat_speed(stat, extstat)
20 u16_t stat;
21 u16_t extstat;
23 int fs, ft;
25 fs= 1;
26 if (stat & MII_STATUS_EXT_STAT)
28 if (extstat & (MII_ESTAT_1000XFD | MII_ESTAT_1000XHD |
29 MII_ESTAT_1000TFD | MII_ESTAT_1000THD))
31 printf("1000 Mbps: ");
32 fs= 0;
33 ft= 1;
34 if (extstat & (MII_ESTAT_1000XFD | MII_ESTAT_1000XHD))
36 ft= 0;
37 printf("X-");
38 switch(extstat &
39 (MII_ESTAT_1000XFD|MII_ESTAT_1000XHD))
41 case MII_ESTAT_1000XFD: printf("FD"); break;
42 case MII_ESTAT_1000XHD: printf("HD"); break;
43 default: printf("FD/HD"); break;
46 if (extstat & (MII_ESTAT_1000TFD | MII_ESTAT_1000THD))
48 if (!ft)
49 printf(", ");
50 ft= 0;
51 printf("T-");
52 switch(extstat &
53 (MII_ESTAT_1000TFD|MII_ESTAT_1000THD))
55 case MII_ESTAT_1000TFD: printf("FD"); break;
56 case MII_ESTAT_1000THD: printf("HD"); break;
57 default: printf("FD/HD"); break;
62 if (stat & (MII_STATUS_100T4 |
63 MII_STATUS_100XFD | MII_STATUS_100XHD |
64 MII_STATUS_100T2FD | MII_STATUS_100T2HD))
66 if (!fs)
67 printf(", ");
68 fs= 0;
69 printf("100 Mbps: ");
70 ft= 1;
71 if (stat & MII_STATUS_100T4)
73 printf("T4");
74 ft= 0;
76 if (stat & (MII_STATUS_100XFD | MII_STATUS_100XHD))
78 if (!ft)
79 printf(", ");
80 ft= 0;
81 printf("TX-");
82 switch(stat & (MII_STATUS_100XFD|MII_STATUS_100XHD))
84 case MII_STATUS_100XFD: printf("FD"); break;
85 case MII_STATUS_100XHD: printf("HD"); break;
86 default: printf("FD/HD"); break;
89 if (stat & (MII_STATUS_100T2FD | MII_STATUS_100T2HD))
91 if (!ft)
92 printf(", ");
93 ft= 0;
94 printf("T2-");
95 switch(stat & (MII_STATUS_100T2FD|MII_STATUS_100T2HD))
97 case MII_STATUS_100T2FD: printf("FD"); break;
98 case MII_STATUS_100T2HD: printf("HD"); break;
99 default: printf("FD/HD"); break;
103 if (stat & (MII_STATUS_10FD | MII_STATUS_10HD))
105 if (!fs)
106 printf(", ");
107 printf("10 Mbps: ");
108 fs= 0;
109 printf("T-");
110 switch(stat & (MII_STATUS_10FD|MII_STATUS_10HD))
112 case MII_STATUS_10FD: printf("FD"); break;
113 case MII_STATUS_10HD: printf("HD"); break;
114 default: printf("FD/HD"); break;
119 /*===========================================================================*
120 * mii_print_techab *
121 *===========================================================================*/
122 PUBLIC void mii_print_techab(techab)
123 u16_t techab;
125 int fs, ft;
127 if ((techab & MII_ANA_SEL_M) != MII_ANA_SEL_802_3)
129 printf("strange selector 0x%x, value 0x%x",
130 techab & MII_ANA_SEL_M,
131 (techab & MII_ANA_TAF_M) >> MII_ANA_TAF_S);
132 return;
134 fs= 1;
135 if (techab & (MII_ANA_100T4 | MII_ANA_100TXFD | MII_ANA_100TXHD))
137 printf("100 Mbps: ");
138 fs= 0;
139 ft= 1;
140 if (techab & MII_ANA_100T4)
142 printf("T4");
143 ft= 0;
145 if (techab & (MII_ANA_100TXFD | MII_ANA_100TXHD))
147 if (!ft)
148 printf(", ");
149 ft= 0;
150 printf("TX-");
151 switch(techab & (MII_ANA_100TXFD|MII_ANA_100TXHD))
153 case MII_ANA_100TXFD: printf("FD"); break;
154 case MII_ANA_100TXHD: printf("HD"); break;
155 default: printf("FD/HD"); break;
159 if (techab & (MII_ANA_10TFD | MII_ANA_10THD))
161 if (!fs)
162 printf(", ");
163 printf("10 Mbps: ");
164 fs= 0;
165 printf("T-");
166 switch(techab & (MII_ANA_10TFD|MII_ANA_10THD))
168 case MII_ANA_10TFD: printf("FD"); break;
169 case MII_ANA_10THD: printf("HD"); break;
170 default: printf("FD/HD"); break;
173 if (techab & MII_ANA_PAUSE_SYM)
175 if (!fs)
176 printf(", ");
177 fs= 0;
178 printf("pause(SYM)");
180 if (techab & MII_ANA_PAUSE_ASYM)
182 if (!fs)
183 printf(", ");
184 fs= 0;
185 printf("pause(ASYM)");
187 if (techab & MII_ANA_TAF_RES)
189 if (!fs)
190 printf(", ");
191 fs= 0;
192 printf("0x%x", (techab & MII_ANA_TAF_RES) >> MII_ANA_TAF_S);
197 * $PchId: mii.c,v 1.2 2005/01/31 22:17:26 philip Exp $