blob: fd6415c95fc6bf595f2a661e40cebb46c65ad9ad [file] [log] [blame]
Stuart Hodgson2edf5672012-05-18 15:58:45 +01001/****************************************************************************
2 * Support for Solarflare Solarstorm network controllers and boards
3 * Copyright 2010 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#include <stdio.h>
11#include "internal.h"
Vidya Sagar Ravipati7a4c4222016-08-23 06:30:31 -070012#include "sff-common.h"
Stuart Hodgson2edf5672012-05-18 15:58:45 +010013
14static void sff8079_show_identifier(const __u8 *id)
15{
Vidya Sagar Ravipati7a4c4222016-08-23 06:30:31 -070016 sff8024_show_identifier(id, 0);
Stuart Hodgson2edf5672012-05-18 15:58:45 +010017}
18
19static void sff8079_show_ext_identifier(const __u8 *id)
20{
Aurelien Guillaume749f3872012-12-02 21:21:01 +010021 printf("\t%-41s : 0x%02x", "Extended identifier", id[1]);
Stuart Hodgson2edf5672012-05-18 15:58:45 +010022 if (id[1] == 0x00)
23 printf(" (GBIC not specified / not MOD_DEF compliant)\n");
24 else if (id[1] == 0x04)
25 printf(" (GBIC/SFP defined by 2-wire interface ID)\n");
26 else if (id[1] <= 0x07)
27 printf(" (GBIC compliant with MOD_DEF %u)\n", id[1]);
28 else
29 printf(" (unknown)\n");
30}
31
32static void sff8079_show_connector(const __u8 *id)
33{
Vidya Sagar Ravipati7a4c4222016-08-23 06:30:31 -070034 sff8024_show_connector(id, 2);
Stuart Hodgson2edf5672012-05-18 15:58:45 +010035}
36
37static void sff8079_show_transceiver(const __u8 *id)
38{
Aurelien Guillaume749f3872012-12-02 21:21:01 +010039 static const char *pfx =
40 "\tTransceiver type :";
Stuart Hodgson2edf5672012-05-18 15:58:45 +010041
Aurelien Guillaume749f3872012-12-02 21:21:01 +010042 printf("\t%-41s : 0x%02x 0x%02x 0x%02x " \
Stuart Hodgson2edf5672012-05-18 15:58:45 +010043 "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
Aurelien Guillaume749f3872012-12-02 21:21:01 +010044 "Transceiver codes",
Stuart Hodgson2edf5672012-05-18 15:58:45 +010045 id[3], id[4], id[5], id[6],
46 id[7], id[8], id[9], id[10]);
47 /* 10G Ethernet Compliance Codes */
48 if (id[3] & (1 << 7))
49 printf("%s 10G Ethernet: 10G Base-ER" \
50 " [SFF-8472 rev10.4 only]\n", pfx);
51 if (id[3] & (1 << 6))
52 printf("%s 10G Ethernet: 10G Base-LRM\n", pfx);
53 if (id[3] & (1 << 5))
54 printf("%s 10G Ethernet: 10G Base-LR\n", pfx);
55 if (id[3] & (1 << 4))
56 printf("%s 10G Ethernet: 10G Base-SR\n", pfx);
57 /* Infiniband Compliance Codes */
58 if (id[3] & (1 << 3))
59 printf("%s Infiniband: 1X SX\n", pfx);
60 if (id[3] & (1 << 2))
61 printf("%s Infiniband: 1X LX\n", pfx);
62 if (id[3] & (1 << 1))
63 printf("%s Infiniband: 1X Copper Active\n", pfx);
64 if (id[3] & (1 << 0))
65 printf("%s Infiniband: 1X Copper Passive\n", pfx);
66 /* ESCON Compliance Codes */
67 if (id[4] & (1 << 7))
68 printf("%s ESCON: ESCON MMF, 1310nm LED\n", pfx);
69 if (id[4] & (1 << 6))
70 printf("%s ESCON: ESCON SMF, 1310nm Laser\n", pfx);
71 /* SONET Compliance Codes */
72 if (id[4] & (1 << 5))
73 printf("%s SONET: OC-192, short reach\n", pfx);
74 if (id[4] & (1 << 4))
75 printf("%s SONET: SONET reach specifier bit 1\n", pfx);
76 if (id[4] & (1 << 3))
77 printf("%s SONET: SONET reach specifier bit 2\n", pfx);
78 if (id[4] & (1 << 2))
79 printf("%s SONET: OC-48, long reach\n", pfx);
80 if (id[4] & (1 << 1))
81 printf("%s SONET: OC-48, intermediate reach\n", pfx);
82 if (id[4] & (1 << 0))
83 printf("%s SONET: OC-48, short reach\n", pfx);
84 if (id[5] & (1 << 6))
85 printf("%s SONET: OC-12, single mode, long reach\n", pfx);
86 if (id[5] & (1 << 5))
87 printf("%s SONET: OC-12, single mode, inter. reach\n", pfx);
88 if (id[5] & (1 << 4))
89 printf("%s SONET: OC-12, short reach\n", pfx);
90 if (id[5] & (1 << 2))
91 printf("%s SONET: OC-3, single mode, long reach\n", pfx);
92 if (id[5] & (1 << 1))
93 printf("%s SONET: OC-3, single mode, inter. reach\n", pfx);
94 if (id[5] & (1 << 0))
95 printf("%s SONET: OC-3, short reach\n", pfx);
96 /* Ethernet Compliance Codes */
97 if (id[6] & (1 << 7))
98 printf("%s Ethernet: BASE-PX\n", pfx);
99 if (id[6] & (1 << 6))
100 printf("%s Ethernet: BASE-BX10\n", pfx);
101 if (id[6] & (1 << 5))
102 printf("%s Ethernet: 100BASE-FX\n", pfx);
103 if (id[6] & (1 << 4))
104 printf("%s Ethernet: 100BASE-LX/LX10\n", pfx);
105 if (id[6] & (1 << 3))
106 printf("%s Ethernet: 1000BASE-T\n", pfx);
107 if (id[6] & (1 << 2))
108 printf("%s Ethernet: 1000BASE-CX\n", pfx);
109 if (id[6] & (1 << 1))
110 printf("%s Ethernet: 1000BASE-LX\n", pfx);
111 if (id[6] & (1 << 0))
112 printf("%s Ethernet: 1000BASE-SX\n", pfx);
113 /* Fibre Channel link length */
114 if (id[7] & (1 << 7))
115 printf("%s FC: very long distance (V)\n", pfx);
116 if (id[7] & (1 << 6))
117 printf("%s FC: short distance (S)\n", pfx);
118 if (id[7] & (1 << 5))
119 printf("%s FC: intermediate distance (I)\n", pfx);
120 if (id[7] & (1 << 4))
121 printf("%s FC: long distance (L)\n", pfx);
122 if (id[7] & (1 << 3))
123 printf("%s FC: medium distance (M)\n", pfx);
124 /* Fibre Channel transmitter technology */
125 if (id[7] & (1 << 2))
126 printf("%s FC: Shortwave laser, linear Rx (SA)\n", pfx);
127 if (id[7] & (1 << 1))
128 printf("%s FC: Longwave laser (LC)\n", pfx);
129 if (id[7] & (1 << 0))
130 printf("%s FC: Electrical inter-enclosure (EL)\n", pfx);
131 if (id[8] & (1 << 7))
132 printf("%s FC: Electrical intra-enclosure (EL)\n", pfx);
133 if (id[8] & (1 << 6))
134 printf("%s FC: Shortwave laser w/o OFC (SN)\n", pfx);
135 if (id[8] & (1 << 5))
136 printf("%s FC: Shortwave laser with OFC (SL)\n", pfx);
137 if (id[8] & (1 << 4))
138 printf("%s FC: Longwave laser (LL)\n", pfx);
139 if (id[8] & (1 << 3))
140 printf("%s FC: Copper Active\n", pfx);
141 if (id[8] & (1 << 2))
142 printf("%s FC: Copper Passive\n", pfx);
143 if (id[8] & (1 << 1))
144 printf("%s FC: Copper FC-BaseT\n", pfx);
145 /* Fibre Channel transmission media */
146 if (id[9] & (1 << 7))
147 printf("%s FC: Twin Axial Pair (TW)\n", pfx);
148 if (id[9] & (1 << 6))
149 printf("%s FC: Twisted Pair (TP)\n", pfx);
150 if (id[9] & (1 << 5))
151 printf("%s FC: Miniature Coax (MI)\n", pfx);
152 if (id[9] & (1 << 4))
153 printf("%s FC: Video Coax (TV)\n", pfx);
154 if (id[9] & (1 << 3))
155 printf("%s FC: Multimode, 62.5um (M6)\n", pfx);
156 if (id[9] & (1 << 2))
157 printf("%s FC: Multimode, 50um (M5)\n", pfx);
158 if (id[9] & (1 << 0))
159 printf("%s FC: Single Mode (SM)\n", pfx);
160 /* Fibre Channel speed */
161 if (id[10] & (1 << 7))
162 printf("%s FC: 1200 MBytes/sec\n", pfx);
163 if (id[10] & (1 << 6))
164 printf("%s FC: 800 MBytes/sec\n", pfx);
165 if (id[10] & (1 << 4))
166 printf("%s FC: 400 MBytes/sec\n", pfx);
167 if (id[10] & (1 << 2))
168 printf("%s FC: 200 MBytes/sec\n", pfx);
169 if (id[10] & (1 << 0))
170 printf("%s FC: 100 MBytes/sec\n", pfx);
171}
172
173static void sff8079_show_encoding(const __u8 *id)
174{
Vidya Sagar Ravipati7a4c4222016-08-23 06:30:31 -0700175 sff8024_show_encoding(id, 11, ETH_MODULE_SFF_8472);
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100176}
177
178static void sff8079_show_rate_identifier(const __u8 *id)
179{
Aurelien Guillaume749f3872012-12-02 21:21:01 +0100180 printf("\t%-41s : 0x%02x", "Rate identifier", id[13]);
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100181 switch (id[13]) {
182 case 0x00:
183 printf(" (unspecified)\n");
184 break;
185 case 0x01:
186 printf(" (4/2/1G Rate_Select & AS0/AS1)\n");
187 break;
188 case 0x02:
189 printf(" (8/4/2G Rx Rate_Select only)\n");
190 break;
191 case 0x03:
192 printf(" (8/4/2G Independent Rx & Tx Rate_Select)\n");
193 break;
194 case 0x04:
195 printf(" (8/4/2G Tx Rate_Select only)\n");
196 break;
197 default:
198 printf(" (reserved or unknown)\n");
199 break;
200 }
201}
202
203static void sff8079_show_oui(const __u8 *id)
204{
Aurelien Guillaume749f3872012-12-02 21:21:01 +0100205 printf("\t%-41s : %02x:%02x:%02x\n", "Vendor OUI",
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100206 id[37], id[38], id[39]);
207}
208
209static void sff8079_show_wavelength_or_copper_compliance(const __u8 *id)
210{
211 if (id[8] & (1 << 2)) {
Aurelien Guillaume749f3872012-12-02 21:21:01 +0100212 printf("\t%-41s : 0x%02x", "Passive Cu cmplnce.", id[60]);
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100213 switch (id[60]) {
214 case 0x00:
215 printf(" (unspecified)");
216 break;
217 case 0x01:
218 printf(" (SFF-8431 appendix E)");
219 break;
220 default:
221 printf(" (unknown)");
222 break;
223 }
224 printf(" [SFF-8472 rev10.4 only]\n");
225 } else if (id[8] & (1 << 3)) {
Aurelien Guillaume749f3872012-12-02 21:21:01 +0100226 printf("\t%-41s : 0x%02x", "Active Cu cmplnce.", id[60]);
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100227 switch (id[60]) {
228 case 0x00:
229 printf(" (unspecified)");
230 break;
231 case 0x01:
232 printf(" (SFF-8431 appendix E)");
233 break;
234 case 0x04:
235 printf(" (SFF-8431 limiting)");
236 break;
237 default:
238 printf(" (unknown)");
239 break;
240 }
241 printf(" [SFF-8472 rev10.4 only]\n");
242 } else {
Aurelien Guillaume749f3872012-12-02 21:21:01 +0100243 printf("\t%-41s : %unm\n", "Laser wavelength",
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100244 (id[60] << 8) | id[61]);
245 }
246}
247
248static void sff8079_show_value_with_unit(const __u8 *id, unsigned int reg,
249 const char *name, unsigned int mult,
250 const char *unit)
251{
252 unsigned int val = id[reg];
253
Aurelien Guillaume749f3872012-12-02 21:21:01 +0100254 printf("\t%-41s : %u%s\n", name, val * mult, unit);
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100255}
256
257static void sff8079_show_ascii(const __u8 *id, unsigned int first_reg,
258 unsigned int last_reg, const char *name)
259{
260 unsigned int reg, val;
261
Aurelien Guillaume749f3872012-12-02 21:21:01 +0100262 printf("\t%-41s : ", name);
Ed Swierk8d87f2e2015-05-18 19:46:48 -0700263 while (first_reg <= last_reg && id[last_reg] == ' ')
264 last_reg--;
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100265 for (reg = first_reg; reg <= last_reg; reg++) {
266 val = id[reg];
267 putchar(((val >= 32) && (val <= 126)) ? val : '_');
268 }
269 printf("\n");
270}
271
Ed Swierk8d87f2e2015-05-18 19:46:48 -0700272static void sff8079_show_options(const __u8 *id)
273{
274 static const char *pfx =
275 "\tOption :";
276
277 printf("\t%-41s : 0x%02x 0x%02x\n", "Option values", id[64], id[65]);
278 if (id[65] & (1 << 1))
279 printf("%s RX_LOS implemented\n", pfx);
280 if (id[65] & (1 << 2))
281 printf("%s RX_LOS implemented, inverted\n", pfx);
282 if (id[65] & (1 << 3))
283 printf("%s TX_FAULT implemented\n", pfx);
284 if (id[65] & (1 << 4))
285 printf("%s TX_DISABLE implemented\n", pfx);
286 if (id[65] & (1 << 5))
287 printf("%s RATE_SELECT implemented\n", pfx);
288 if (id[65] & (1 << 6))
289 printf("%s Tunable transmitter technology\n", pfx);
290 if (id[65] & (1 << 7))
291 printf("%s Receiver decision threshold implemented\n", pfx);
292 if (id[64] & (1 << 0))
293 printf("%s Linear receiver output implemented\n", pfx);
294 if (id[64] & (1 << 1))
295 printf("%s Power level 2 requirement\n", pfx);
296 if (id[64] & (1 << 2))
297 printf("%s Cooled transceiver implemented\n", pfx);
298 if (id[64] & (1 << 3))
299 printf("%s Retimer or CDR implemented\n", pfx);
300 if (id[64] & (1 << 4))
301 printf("%s Paging implemented\n", pfx);
302 if (id[64] & (1 << 5))
303 printf("%s Power level 3 requirement\n", pfx);
304}
305
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100306void sff8079_show_all(const __u8 *id)
307{
308 sff8079_show_identifier(id);
Andrew Lunn0b2a8f12015-08-16 04:05:18 +0200309 if (((id[0] == 0x02) || (id[0] == 0x03)) && (id[1] == 0x04)) {
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100310 sff8079_show_ext_identifier(id);
311 sff8079_show_connector(id);
312 sff8079_show_transceiver(id);
313 sff8079_show_encoding(id);
314 sff8079_show_value_with_unit(id, 12, "BR, Nominal", 100, "MBd");
315 sff8079_show_rate_identifier(id);
316 sff8079_show_value_with_unit(id, 14,
317 "Length (SMF,km)", 1, "km");
318 sff8079_show_value_with_unit(id, 15, "Length (SMF)", 100, "m");
319 sff8079_show_value_with_unit(id, 16, "Length (50um)", 10, "m");
320 sff8079_show_value_with_unit(id, 17,
321 "Length (62.5um)", 10, "m");
322 sff8079_show_value_with_unit(id, 18, "Length (Copper)", 1, "m");
323 sff8079_show_value_with_unit(id, 19, "Length (OM3)", 10, "m");
324 sff8079_show_wavelength_or_copper_compliance(id);
325 sff8079_show_ascii(id, 20, 35, "Vendor name");
326 sff8079_show_oui(id);
327 sff8079_show_ascii(id, 40, 55, "Vendor PN");
328 sff8079_show_ascii(id, 56, 59, "Vendor rev");
Ed Swierk8d87f2e2015-05-18 19:46:48 -0700329 sff8079_show_options(id);
330 sff8079_show_value_with_unit(id, 66, "BR margin, max", 1, "%");
331 sff8079_show_value_with_unit(id, 67, "BR margin, min", 1, "%");
332 sff8079_show_ascii(id, 68, 83, "Vendor SN");
333 sff8079_show_ascii(id, 84, 91, "Date code");
Stuart Hodgson2edf5672012-05-18 15:58:45 +0100334 }
335}