Deleted Added
full compact
lmcconfig.c (216599) lmcconfig.c (216600)
1/*
2 * First author: Michael Graff.
3 * Copyright (c) 1997-2000 Lan Media Corp. (www.lanmedia.com).
4 * All rights reserved.
5 *
6 * Second author: Andrew Stanley-Jones.
7 * Copyright (c) 2000-2002 SBE Corp. (www.sbei.com).
8 * All rights reserved.

--- 48 unchanged lines hidden (view full) ---

57 * There is a man page for this program; go find it.
58 *
59 * If Netgraph is present (FreeBSD only):
60 * cc -o lmcconfig -l netgraph -D NETGRAPH lmcconfig.c
61 * If Netgraph is NOT present:
62 * cc -o lmcconfig lmcconfig.c
63 * Install the executable program in /usr/local/sbin/lmcconfig.
64 *
1/*
2 * First author: Michael Graff.
3 * Copyright (c) 1997-2000 Lan Media Corp. (www.lanmedia.com).
4 * All rights reserved.
5 *
6 * Second author: Andrew Stanley-Jones.
7 * Copyright (c) 2000-2002 SBE Corp. (www.sbei.com).
8 * All rights reserved.

--- 48 unchanged lines hidden (view full) ---

57 * There is a man page for this program; go find it.
58 *
59 * If Netgraph is present (FreeBSD only):
60 * cc -o lmcconfig -l netgraph -D NETGRAPH lmcconfig.c
61 * If Netgraph is NOT present:
62 * cc -o lmcconfig lmcconfig.c
63 * Install the executable program in /usr/local/sbin/lmcconfig.
64 *
65 * $FreeBSD: head/usr.sbin/lmcconfig/lmcconfig.c 216599 2010-12-20 19:08:07Z uqs $
65 * $FreeBSD: head/usr.sbin/lmcconfig/lmcconfig.c 216600 2010-12-20 19:08:15Z uqs $
66 */
67
66 */
67
68#include <stdio.h>
68#include <sys/param.h>
69#include <sys/ioctl.h>
70#include <sys/socket.h>
71
69#include <errno.h>
72#include <errno.h>
73#include <inttypes.h>
74#include <stdio.h>
70#include <stdlib.h>
71#include <string.h>
72#include <strings.h>
75#include <stdlib.h>
76#include <string.h>
77#include <strings.h>
78#include <time.h>
73#include <unistd.h>
74#if defined(NETGRAPH)
75# include <netgraph.h>
76#endif
79#include <unistd.h>
80#if defined(NETGRAPH)
81# include <netgraph.h>
82#endif
77#include <sys/param.h>
78#include <sys/types.h>
79#include <sys/time.h>
80#include <sys/ioctl.h>
81#include <sys/socket.h>
82#include <net/if.h>
83
84#include <dev/lmc/if_lmc.h>
85
86/* program global variables */
87char * progname; /* name of this program */
88char * ifname; /* interface name */
89int fdcs; /* ifnet File Desc or ng Ctl Socket */
90struct status status; /* card status (read only) */
91struct config config; /* card configuration (read/write) */
92int netgraph = 0; /* non-zero if netgraph present */
93int summary = 0; /* print summary at end */
94int update = 0; /* update driver config */
95int verbose = 0; /* verbose output */
96u_int8_t checksum; /* gate array ucode file checksum */
97
83#include <net/if.h>
84
85#include <dev/lmc/if_lmc.h>
86
87/* program global variables */
88char * progname; /* name of this program */
89char * ifname; /* interface name */
90int fdcs; /* ifnet File Desc or ng Ctl Socket */
91struct status status; /* card status (read only) */
92struct config config; /* card configuration (read/write) */
93int netgraph = 0; /* non-zero if netgraph present */
94int summary = 0; /* print summary at end */
95int update = 0; /* update driver config */
96int verbose = 0; /* verbose output */
97u_int8_t checksum; /* gate array ucode file checksum */
98
98void usage()
99 {
99/* Functions currently unused. Keep compiler happy and provide prototypes. */
100void ioctl_snmp_loop(u_int32_t);
101void init_srom(int);
102
103static void
104usage(void)
105{
100 fprintf(stderr, "Usage: %s interface [-abBcCdDeEfhiLmMpPsStTuUvVwWxXyYzZ?]\n", progname);
101 fprintf(stderr, "or\n");
102 fprintf(stderr, "Usage: %s interface -1 [-aABcdeEfFgiIlLpPstTuUvxX]\n", progname);
103 fprintf(stderr, "or\n");
104 fprintf(stderr, "Usage: %s interface -3 [-aABcdefFlLsSvV]\n\n", progname);
105 fprintf(stderr, "\tInterface is the interface name, e.g. '%s'\n", ifname);
106#if defined(NETGRAPH)
107 fprintf(stderr, "\tIf interface name ends with ':' then use netgraph\n");

--- 34 unchanged lines hidden (view full) ---

142 fprintf(stderr, "\t-X Select line protocols: SPPP, P2P or HDLC\n");
143 fprintf(stderr, "\t-y disable SPPP keep-alive packets\n");
144 fprintf(stderr, "\t-Y enable SPPP keep-alive packets\n");
145 fprintf(stderr, "\t-z Set SPPP line protocol to Cisco-HDLC\n");
146 fprintf(stderr, "\t-Z Set SPPP line protocol to PPP\n");
147
148 fprintf(stderr, "The -1 switch precedes T1/E1 commands.\n");
149 fprintf(stderr, "\t-a <y|b|a> Stop sending Yellow|Blue|AIS signal\n");
106 fprintf(stderr, "Usage: %s interface [-abBcCdDeEfhiLmMpPsStTuUvVwWxXyYzZ?]\n", progname);
107 fprintf(stderr, "or\n");
108 fprintf(stderr, "Usage: %s interface -1 [-aABcdeEfFgiIlLpPstTuUvxX]\n", progname);
109 fprintf(stderr, "or\n");
110 fprintf(stderr, "Usage: %s interface -3 [-aABcdefFlLsSvV]\n\n", progname);
111 fprintf(stderr, "\tInterface is the interface name, e.g. '%s'\n", ifname);
112#if defined(NETGRAPH)
113 fprintf(stderr, "\tIf interface name ends with ':' then use netgraph\n");

--- 34 unchanged lines hidden (view full) ---

148 fprintf(stderr, "\t-X Select line protocols: SPPP, P2P or HDLC\n");
149 fprintf(stderr, "\t-y disable SPPP keep-alive packets\n");
150 fprintf(stderr, "\t-Y enable SPPP keep-alive packets\n");
151 fprintf(stderr, "\t-z Set SPPP line protocol to Cisco-HDLC\n");
152 fprintf(stderr, "\t-Z Set SPPP line protocol to PPP\n");
153
154 fprintf(stderr, "The -1 switch precedes T1/E1 commands.\n");
155 fprintf(stderr, "\t-a <y|b|a> Stop sending Yellow|Blue|AIS signal\n");
150 fprintf(stderr, "\t-A <y|b|a> Start sending Yellow|Blue}AIS signal\n");
156 fprintf(stderr, "\t-A <y|b|a> Start sending Yellow|Blue|AIS signal\n");
151 fprintf(stderr, "\t-B <number> Send BOP msg 25 times\n");
152 fprintf(stderr, "\t-c <number> Set cable length in meters\n");
153 fprintf(stderr, "\t-d Print status of T1 DSU/CSU\n");
154 fprintf(stderr, "\t-e <number> Set framing format, where:\n");
155 fprintf(stderr, "\t 27:T1-ESF 9:T1-SF 0:E1-FAS 8:E1-FAS+CRC\n");
156 fprintf(stderr, "\t 16:E1-FAS+CAS 24:E1-FAS+CRC+CAS 32:E1-NO-FRAMING\n");
157 fprintf(stderr, "\t-E <32-bit hex number> 1 activates a channel and 0 deactivates it.\n");
158 fprintf(stderr, "\t Use this to config a link in fractional T1/E1 mode\n");

--- 45 unchanged lines hidden (view full) ---

204 fprintf(stderr, "\t-F <addr> <data> Write Framer register\n");
205 fprintf(stderr, "\t-l Send 'Line Loop Down' BOP msg\n");
206 fprintf(stderr, "\t-L Send 'Line Loop Up' BOP msg\n");
207 fprintf(stderr, "\t-s Print status of T3 DSU/CSU\n");
208 fprintf(stderr, "\t-S <number> Set DS3 scrambler mode, where:\n");
209 fprintf(stderr, "\t 1:OFF 2:DigitalLink|Kentrox 3:Larse\n");
210 fprintf(stderr, "\t-v Set verbose printout mode\n");
211 fprintf(stderr, "\t-V <number> Write to T3 VCXO freq control DAC\n");
157 fprintf(stderr, "\t-B <number> Send BOP msg 25 times\n");
158 fprintf(stderr, "\t-c <number> Set cable length in meters\n");
159 fprintf(stderr, "\t-d Print status of T1 DSU/CSU\n");
160 fprintf(stderr, "\t-e <number> Set framing format, where:\n");
161 fprintf(stderr, "\t 27:T1-ESF 9:T1-SF 0:E1-FAS 8:E1-FAS+CRC\n");
162 fprintf(stderr, "\t 16:E1-FAS+CAS 24:E1-FAS+CRC+CAS 32:E1-NO-FRAMING\n");
163 fprintf(stderr, "\t-E <32-bit hex number> 1 activates a channel and 0 deactivates it.\n");
164 fprintf(stderr, "\t Use this to config a link in fractional T1/E1 mode\n");

--- 45 unchanged lines hidden (view full) ---

210 fprintf(stderr, "\t-F <addr> <data> Write Framer register\n");
211 fprintf(stderr, "\t-l Send 'Line Loop Down' BOP msg\n");
212 fprintf(stderr, "\t-L Send 'Line Loop Up' BOP msg\n");
213 fprintf(stderr, "\t-s Print status of T3 DSU/CSU\n");
214 fprintf(stderr, "\t-S <number> Set DS3 scrambler mode, where:\n");
215 fprintf(stderr, "\t 1:OFF 2:DigitalLink|Kentrox 3:Larse\n");
216 fprintf(stderr, "\t-v Set verbose printout mode\n");
217 fprintf(stderr, "\t-V <number> Write to T3 VCXO freq control DAC\n");
212 }
218}
213
219
214void call_driver(unsigned long cmd, struct iohdr *iohdr)
215 {
220static void
221call_driver(unsigned long cmd, struct iohdr *iohdr)
222{
216 int error = 0;
217
218 strncpy(iohdr->ifname, ifname, sizeof(iohdr->ifname));
219 iohdr->cookie = NGM_LMC_COOKIE;
220 iohdr->iohdr = iohdr;
221
222 /* Exchange data with a running device driver. */
223#if defined(NETGRAPH)

--- 30 unchanged lines hidden (view full) ---

254 }
255
256 if (iohdr->cookie != NGM_LMC_COOKIE)
257 {
258 fprintf(stderr, "%s: cookie = 0x%08X, expected 0x%08X\n", progname, iohdr->cookie, NGM_LMC_COOKIE);
259 fprintf(stderr, "%s: This version of %s is incompatible with the device driver\n", progname, progname);
260 exit(1);
261 }
223 int error = 0;
224
225 strncpy(iohdr->ifname, ifname, sizeof(iohdr->ifname));
226 iohdr->cookie = NGM_LMC_COOKIE;
227 iohdr->iohdr = iohdr;
228
229 /* Exchange data with a running device driver. */
230#if defined(NETGRAPH)

--- 30 unchanged lines hidden (view full) ---

261 }
262
263 if (iohdr->cookie != NGM_LMC_COOKIE)
264 {
265 fprintf(stderr, "%s: cookie = 0x%08X, expected 0x%08X\n", progname, iohdr->cookie, NGM_LMC_COOKIE);
266 fprintf(stderr, "%s: This version of %s is incompatible with the device driver\n", progname, progname);
267 exit(1);
268 }
262 }
269}
263
270
264u_int32_t read_pci_config(u_int8_t addr)
265 {
271static u_int32_t
272read_pci_config(u_int8_t addr)
273{
266 struct ioctl ioctl;
267
268 ioctl.iohdr.direction = DIR_IOWR;
269 ioctl.iohdr.length = sizeof(struct ioctl);
270 ioctl.cmd = IOCTL_RW_PCI;
271 ioctl.address = addr;
272
273 call_driver(LMCIOCREAD, &ioctl.iohdr);
274
275 return ioctl.data;
274 struct ioctl ioctl;
275
276 ioctl.iohdr.direction = DIR_IOWR;
277 ioctl.iohdr.length = sizeof(struct ioctl);
278 ioctl.cmd = IOCTL_RW_PCI;
279 ioctl.address = addr;
280
281 call_driver(LMCIOCREAD, &ioctl.iohdr);
282
283 return ioctl.data;
276 }
284}
277
285
278void write_pci_config(u_int8_t addr, u_int32_t data)
279 {
286static void
287write_pci_config(u_int8_t addr, u_int32_t data)
288{
280 struct ioctl ioctl;
281
282 ioctl.iohdr.direction = DIR_IOW;
283 ioctl.iohdr.length = sizeof(struct ioctl);
284 ioctl.cmd = IOCTL_RW_PCI;
285 ioctl.address = addr;
286 ioctl.data = data;
287
288 call_driver(LMCIOCWRITE, &ioctl.iohdr);
289 struct ioctl ioctl;
290
291 ioctl.iohdr.direction = DIR_IOW;
292 ioctl.iohdr.length = sizeof(struct ioctl);
293 ioctl.cmd = IOCTL_RW_PCI;
294 ioctl.address = addr;
295 ioctl.data = data;
296
297 call_driver(LMCIOCWRITE, &ioctl.iohdr);
289 }
298}
290
299
291u_int32_t read_csr(u_int8_t addr)
292 {
300static u_int32_t
301read_csr(u_int8_t addr)
302{
293 struct ioctl ioctl;
294
295 ioctl.iohdr.direction = DIR_IOWR;
296 ioctl.iohdr.length = sizeof(struct ioctl);
297 ioctl.cmd = IOCTL_RW_CSR;
298 ioctl.address = addr;
299
300 call_driver(LMCIOCREAD, &ioctl.iohdr);
301
302 return ioctl.data;
303 struct ioctl ioctl;
304
305 ioctl.iohdr.direction = DIR_IOWR;
306 ioctl.iohdr.length = sizeof(struct ioctl);
307 ioctl.cmd = IOCTL_RW_CSR;
308 ioctl.address = addr;
309
310 call_driver(LMCIOCREAD, &ioctl.iohdr);
311
312 return ioctl.data;
303 }
313}
304
314
305void write_csr(u_int8_t addr, u_int32_t data)
306 {
315static void
316write_csr(u_int8_t addr, u_int32_t data)
317{
307 struct ioctl ioctl;
308
309 ioctl.iohdr.direction = DIR_IOW;
310 ioctl.iohdr.length = sizeof(struct ioctl);
311 ioctl.cmd = IOCTL_RW_CSR;
312 ioctl.address = addr;
313 ioctl.data = data;
314
315 call_driver(LMCIOCWRITE, &ioctl.iohdr);
318 struct ioctl ioctl;
319
320 ioctl.iohdr.direction = DIR_IOW;
321 ioctl.iohdr.length = sizeof(struct ioctl);
322 ioctl.cmd = IOCTL_RW_CSR;
323 ioctl.address = addr;
324 ioctl.data = data;
325
326 call_driver(LMCIOCWRITE, &ioctl.iohdr);
316 }
327}
317
328
318u_int16_t read_srom(u_int8_t addr)
319 {
329static u_int16_t
330read_srom(u_int8_t addr)
331{
320 struct ioctl ioctl;
321
322 ioctl.iohdr.direction = DIR_IOWR;
323 ioctl.iohdr.length = sizeof(struct ioctl);
324 ioctl.cmd = IOCTL_RW_SROM;
325 ioctl.address = addr;
326
327 call_driver(LMCIOCREAD, &ioctl.iohdr);
328
329 return ioctl.data;
332 struct ioctl ioctl;
333
334 ioctl.iohdr.direction = DIR_IOWR;
335 ioctl.iohdr.length = sizeof(struct ioctl);
336 ioctl.cmd = IOCTL_RW_SROM;
337 ioctl.address = addr;
338
339 call_driver(LMCIOCREAD, &ioctl.iohdr);
340
341 return ioctl.data;
330 }
342}
331
343
332void write_srom(u_int8_t addr, u_int16_t data)
333 {
344static void
345write_srom(u_int8_t addr, u_int16_t data)
346{
334 struct ioctl ioctl;
335
336 ioctl.iohdr.direction = DIR_IOW;
337 ioctl.iohdr.length = sizeof(struct ioctl);
338 ioctl.cmd = IOCTL_RW_SROM;
339 ioctl.address = addr;
340 ioctl.data = data;
341
342 call_driver(LMCIOCWRITE, &ioctl.iohdr);
347 struct ioctl ioctl;
348
349 ioctl.iohdr.direction = DIR_IOW;
350 ioctl.iohdr.length = sizeof(struct ioctl);
351 ioctl.cmd = IOCTL_RW_SROM;
352 ioctl.address = addr;
353 ioctl.data = data;
354
355 call_driver(LMCIOCWRITE, &ioctl.iohdr);
343 }
356}
344
357
345u_int8_t read_bios_rom(u_int32_t addr)
346 {
358static u_int8_t
359read_bios_rom(u_int32_t addr)
360{
347 struct ioctl ioctl;
348
349 ioctl.iohdr.direction = DIR_IOWR;
350 ioctl.iohdr.length = sizeof(struct ioctl);
351 ioctl.cmd = IOCTL_RW_BIOS;
352 ioctl.address = addr;
353
354 call_driver(LMCIOCREAD, &ioctl.iohdr);
355
356 return ioctl.data;
361 struct ioctl ioctl;
362
363 ioctl.iohdr.direction = DIR_IOWR;
364 ioctl.iohdr.length = sizeof(struct ioctl);
365 ioctl.cmd = IOCTL_RW_BIOS;
366 ioctl.address = addr;
367
368 call_driver(LMCIOCREAD, &ioctl.iohdr);
369
370 return ioctl.data;
357 }
371}
358
372
359void write_bios_rom(u_int32_t addr, u_int8_t data)
360 {
373static void
374write_bios_rom(u_int32_t addr, u_int8_t data)
375{
361 struct ioctl ioctl;
362
363 ioctl.iohdr.direction = DIR_IOW;
364 ioctl.iohdr.length = sizeof(struct ioctl);
365 ioctl.cmd = IOCTL_RW_BIOS;
366 ioctl.address = addr;
367 ioctl.data = data;
368
369 call_driver(LMCIOCWRITE, &ioctl.iohdr);
376 struct ioctl ioctl;
377
378 ioctl.iohdr.direction = DIR_IOW;
379 ioctl.iohdr.length = sizeof(struct ioctl);
380 ioctl.cmd = IOCTL_RW_BIOS;
381 ioctl.address = addr;
382 ioctl.data = data;
383
384 call_driver(LMCIOCWRITE, &ioctl.iohdr);
370 }
385}
371
386
372u_int16_t read_mii(u_int8_t addr)
373 {
387static u_int16_t
388read_mii(u_int8_t addr)
389{
374 struct ioctl ioctl;
375
376 ioctl.iohdr.direction = DIR_IOWR;
377 ioctl.iohdr.length = sizeof(struct ioctl);
378 ioctl.cmd = IOCTL_RW_MII;
379 ioctl.address = addr;
380
381 call_driver(LMCIOCREAD, &ioctl.iohdr);
382
383 return ioctl.data;
390 struct ioctl ioctl;
391
392 ioctl.iohdr.direction = DIR_IOWR;
393 ioctl.iohdr.length = sizeof(struct ioctl);
394 ioctl.cmd = IOCTL_RW_MII;
395 ioctl.address = addr;
396
397 call_driver(LMCIOCREAD, &ioctl.iohdr);
398
399 return ioctl.data;
384 }
400}
385
401
386void write_mii(u_int8_t addr, u_int16_t data)
387 {
402static void
403write_mii(u_int8_t addr, u_int16_t data)
404{
388 struct ioctl ioctl;
389
390 ioctl.iohdr.direction = DIR_IOW;
391 ioctl.iohdr.length = sizeof(struct ioctl);
392 ioctl.cmd = IOCTL_RW_MII;
393 ioctl.address = addr;
394 ioctl.data = data;
395
396 call_driver(LMCIOCWRITE, &ioctl.iohdr);
405 struct ioctl ioctl;
406
407 ioctl.iohdr.direction = DIR_IOW;
408 ioctl.iohdr.length = sizeof(struct ioctl);
409 ioctl.cmd = IOCTL_RW_MII;
410 ioctl.address = addr;
411 ioctl.data = data;
412
413 call_driver(LMCIOCWRITE, &ioctl.iohdr);
397 }
414}
398
415
399unsigned char read_framer(u_int16_t addr)
400 {
416static unsigned char
417read_framer(u_int16_t addr)
418{
401 struct ioctl ioctl;
402
403 ioctl.iohdr.direction = DIR_IOWR;
404 ioctl.iohdr.length = sizeof(struct ioctl);
405 ioctl.cmd = IOCTL_RW_FRAME;
406 ioctl.address = addr;
407
408 call_driver(LMCIOCREAD, &ioctl.iohdr);
409
410 return ioctl.data;
419 struct ioctl ioctl;
420
421 ioctl.iohdr.direction = DIR_IOWR;
422 ioctl.iohdr.length = sizeof(struct ioctl);
423 ioctl.cmd = IOCTL_RW_FRAME;
424 ioctl.address = addr;
425
426 call_driver(LMCIOCREAD, &ioctl.iohdr);
427
428 return ioctl.data;
411 }
429}
412
430
413void write_framer(u_int16_t addr, u_int8_t data)
414 {
431static void
432write_framer(u_int16_t addr, u_int8_t data)
433{
415 struct ioctl ioctl;
416
417 ioctl.iohdr.direction = DIR_IOW;
418 ioctl.iohdr.length = sizeof(struct ioctl);
419 ioctl.cmd = IOCTL_RW_FRAME;
420 ioctl.address = addr;
421 ioctl.data = data;
422
423 call_driver(LMCIOCWRITE, &ioctl.iohdr);
434 struct ioctl ioctl;
435
436 ioctl.iohdr.direction = DIR_IOW;
437 ioctl.iohdr.length = sizeof(struct ioctl);
438 ioctl.cmd = IOCTL_RW_FRAME;
439 ioctl.address = addr;
440 ioctl.data = data;
441
442 call_driver(LMCIOCWRITE, &ioctl.iohdr);
424 }
443}
425
444
426void write_synth(struct synth synth)
427 {
445static void
446write_synth(struct synth synth)
447{
428 struct ioctl ioctl;
429
430 ioctl.iohdr.direction = DIR_IOW;
431 ioctl.iohdr.length = sizeof(struct ioctl);
432 ioctl.cmd = IOCTL_WO_SYNTH;
433 bcopy(&synth, &ioctl.data, sizeof(synth));
434
435 call_driver(LMCIOCWRITE, &ioctl.iohdr);
448 struct ioctl ioctl;
449
450 ioctl.iohdr.direction = DIR_IOW;
451 ioctl.iohdr.length = sizeof(struct ioctl);
452 ioctl.cmd = IOCTL_WO_SYNTH;
453 bcopy(&synth, &ioctl.data, sizeof(synth));
454
455 call_driver(LMCIOCWRITE, &ioctl.iohdr);
436 }
456}
437
457
438void write_dac(u_int16_t data)
439 {
458static void
459write_dac(u_int16_t data)
460{
440 struct ioctl ioctl;
441
442 ioctl.iohdr.direction = DIR_IOW;
443 ioctl.iohdr.length = sizeof(struct ioctl);
444 ioctl.cmd = IOCTL_WO_DAC;
445 ioctl.data = data;
446
447 call_driver(LMCIOCWRITE, &ioctl.iohdr);
461 struct ioctl ioctl;
462
463 ioctl.iohdr.direction = DIR_IOW;
464 ioctl.iohdr.length = sizeof(struct ioctl);
465 ioctl.cmd = IOCTL_WO_DAC;
466 ioctl.data = data;
467
468 call_driver(LMCIOCWRITE, &ioctl.iohdr);
448 }
469}
449
470
450void reset_xilinx()
451 {
471static void
472reset_xilinx(void)
473{
452 struct ioctl ioctl;
453
454 ioctl.iohdr.direction = DIR_IOWR;
455 ioctl.iohdr.length = sizeof(struct ioctl);
456 ioctl.cmd = IOCTL_XILINX_RESET;
457
458 call_driver(LMCIOCTL, &ioctl.iohdr);
474 struct ioctl ioctl;
475
476 ioctl.iohdr.direction = DIR_IOWR;
477 ioctl.iohdr.length = sizeof(struct ioctl);
478 ioctl.cmd = IOCTL_XILINX_RESET;
479
480 call_driver(LMCIOCTL, &ioctl.iohdr);
459 }
481}
460
482
461void load_xilinx_from_rom()
462 {
483static void
484load_xilinx_from_rom(void)
485{
463 struct ioctl ioctl;
464
465 ioctl.iohdr.direction = DIR_IOWR;
466 ioctl.iohdr.length = sizeof(struct ioctl);
467 ioctl.cmd = IOCTL_XILINX_ROM;
468
469 call_driver(LMCIOCTL, &ioctl.iohdr);
486 struct ioctl ioctl;
487
488 ioctl.iohdr.direction = DIR_IOWR;
489 ioctl.iohdr.length = sizeof(struct ioctl);
490 ioctl.cmd = IOCTL_XILINX_ROM;
491
492 call_driver(LMCIOCTL, &ioctl.iohdr);
470 }
493}
471
494
472void load_xilinx_from_file(char *ucode, u_int32_t len)
473 {
495static void
496load_xilinx_from_file(char *ucode, u_int32_t len)
497{
474 struct ioctl ioctl;
475
476 ioctl.iohdr.direction = DIR_IOWR;
477 ioctl.iohdr.length = sizeof(struct ioctl);
478 ioctl.cmd = IOCTL_XILINX_FILE;
479 ioctl.data = len;
480 ioctl.ucode = ucode;
481
482 call_driver(LMCIOCTL, &ioctl.iohdr);
498 struct ioctl ioctl;
499
500 ioctl.iohdr.direction = DIR_IOWR;
501 ioctl.iohdr.length = sizeof(struct ioctl);
502 ioctl.cmd = IOCTL_XILINX_FILE;
503 ioctl.data = len;
504 ioctl.ucode = ucode;
505
506 call_driver(LMCIOCTL, &ioctl.iohdr);
483 }
507}
484
508
485void ioctl_snmp_send(u_int32_t send)
486 {
509static void
510ioctl_snmp_send(u_int32_t send)
511{
487 struct ioctl ioctl;
488
489 ioctl.iohdr.direction = DIR_IOWR;
490 ioctl.iohdr.length = sizeof(struct ioctl);
491 ioctl.cmd = IOCTL_SNMP_SEND;
492 ioctl.data = send;
493
494 call_driver(LMCIOCTL, &ioctl.iohdr);
512 struct ioctl ioctl;
513
514 ioctl.iohdr.direction = DIR_IOWR;
515 ioctl.iohdr.length = sizeof(struct ioctl);
516 ioctl.cmd = IOCTL_SNMP_SEND;
517 ioctl.data = send;
518
519 call_driver(LMCIOCTL, &ioctl.iohdr);
495 }
520}
496
521
497void ioctl_snmp_loop(u_int32_t loop)
498 {
522void
523ioctl_snmp_loop(u_int32_t loop)
524{
499 struct ioctl ioctl;
500
501 ioctl.iohdr.direction = DIR_IOWR;
502 ioctl.iohdr.length = sizeof(struct ioctl);
503 ioctl.cmd = IOCTL_SNMP_LOOP;
504 ioctl.data = loop;
505
506 call_driver(LMCIOCTL, &ioctl.iohdr);
525 struct ioctl ioctl;
526
527 ioctl.iohdr.direction = DIR_IOWR;
528 ioctl.iohdr.length = sizeof(struct ioctl);
529 ioctl.cmd = IOCTL_SNMP_LOOP;
530 ioctl.data = loop;
531
532 call_driver(LMCIOCTL, &ioctl.iohdr);
507 }
533}
508
534
509void ioctl_reset_cntrs()
510 {
535static void
536ioctl_reset_cntrs(void)
537{
511 struct ioctl ioctl;
512
513 ioctl.iohdr.direction = DIR_IOWR;
514 ioctl.iohdr.length = sizeof(struct ioctl);
515 ioctl.cmd = IOCTL_RESET_CNTRS;
516
517 call_driver(LMCIOCTL, &ioctl.iohdr);
538 struct ioctl ioctl;
539
540 ioctl.iohdr.direction = DIR_IOWR;
541 ioctl.iohdr.length = sizeof(struct ioctl);
542 ioctl.cmd = IOCTL_RESET_CNTRS;
543
544 call_driver(LMCIOCTL, &ioctl.iohdr);
518 }
545}
519
546
520void ioctl_read_config()
521 {
547static void
548ioctl_read_config(void)
549{
522 config.iohdr.direction = DIR_IOWR;
523 config.iohdr.length = sizeof(struct config);
524
525 call_driver(LMCIOCGCFG, &config.iohdr);
550 config.iohdr.direction = DIR_IOWR;
551 config.iohdr.length = sizeof(struct config);
552
553 call_driver(LMCIOCGCFG, &config.iohdr);
526 }
554}
527
555
528void ioctl_write_config()
529 {
556static void
557ioctl_write_config(void)
558{
530 config.iohdr.direction = DIR_IOW;
531 config.iohdr.length = sizeof(struct config);
532
533 call_driver(LMCIOCSCFG, &config.iohdr);
559 config.iohdr.direction = DIR_IOW;
560 config.iohdr.length = sizeof(struct config);
561
562 call_driver(LMCIOCSCFG, &config.iohdr);
534 }
563}
535
564
536void ioctl_read_status()
537 {
565static void
566ioctl_read_status(void)
567{
538 status.iohdr.direction = DIR_IOWR;
539 status.iohdr.length = sizeof(struct status);
540
541 call_driver(LMCIOCGSTAT, &status.iohdr);
568 status.iohdr.direction = DIR_IOWR;
569 status.iohdr.length = sizeof(struct status);
570
571 call_driver(LMCIOCGSTAT, &status.iohdr);
542 }
572}
543
573
544void print_card_name()
545 {
574static void
575print_card_name(void)
576{
546 printf("Card name:\t\t%s\n", ifname);
577 printf("Card name:\t\t%s\n", ifname);
547 }
578}
548
579
549void print_card_type()
550 {
580static void
581print_card_type(void)
582{
551 printf("Card type:\t\t");
552 switch(status.card_type)
553 {
554 case TLP_CSID_HSSI:
555 printf("HSSI (lmc5200)\n");
556 break;
557 case TLP_CSID_T3:
558 printf("T3 (lmc5245)\n");

--- 6 unchanged lines hidden (view full) ---

565 break;
566 case TLP_CSID_HSSIc:
567 printf("HSSI (lmc5200C)\n");
568 break;
569 default:
570 printf("unknown card_type: %d\n", status.card_type);
571 break;
572 }
583 printf("Card type:\t\t");
584 switch(status.card_type)
585 {
586 case TLP_CSID_HSSI:
587 printf("HSSI (lmc5200)\n");
588 break;
589 case TLP_CSID_T3:
590 printf("T3 (lmc5245)\n");

--- 6 unchanged lines hidden (view full) ---

597 break;
598 case TLP_CSID_HSSIc:
599 printf("HSSI (lmc5200C)\n");
600 break;
601 default:
602 printf("unknown card_type: %d\n", status.card_type);
603 break;
604 }
573 }
605}
574
606
575void print_status()
576 {
607static void
608print_status(void)
609{
577 char *status_string;
578
579 if (status.oper_status == STATUS_UP)
580 status_string = "Up";
581 else if (status.oper_status == STATUS_DOWN)
582 status_string = "Down";
583 else if (status.oper_status == STATUS_TEST)
584 status_string = "Test";
585 else
586 status_string = "Unknown";
587 printf("Link status:\t\t%s\n", status_string);
610 char *status_string;
611
612 if (status.oper_status == STATUS_UP)
613 status_string = "Up";
614 else if (status.oper_status == STATUS_DOWN)
615 status_string = "Down";
616 else if (status.oper_status == STATUS_TEST)
617 status_string = "Test";
618 else
619 status_string = "Unknown";
620 printf("Link status:\t\t%s\n", status_string);
588 }
621}
589
622
590void print_tx_speed()
591 {
623static void
624print_tx_speed(void)
625{
592 printf("Tx Speed:\t\t%u\n", status.tx_speed);
626 printf("Tx Speed:\t\t%u\n", status.tx_speed);
593 }
627}
594
628
595void print_debug()
596 {
629static void
630print_debug(void)
631{
597 if (config.debug != 0)
598 printf("Debug:\t\t\t%s\n", "On");
632 if (config.debug != 0)
633 printf("Debug:\t\t\t%s\n", "On");
599 }
634}
600
635
601void print_line_prot()
602 {
636static void
637print_line_prot(void)
638{
603 char *on = "On", *off = "Off";
604
605 printf("Line Prot/Pkg:\t\t");
606 switch (status.line_prot)
607 {
608 case 0:
609 printf("NotSet/");
610 break;

--- 43 unchanged lines hidden (view full) ---

654 default:
655 printf("unknown line_pkg: %d\n", status.line_pkg);
656 break;
657 }
658
659 if (status.line_pkg == PKG_SPPP)
660 printf("SPPP Keep-alives:\t%s\n",
661 config.keep_alive ? on : off);
639 char *on = "On", *off = "Off";
640
641 printf("Line Prot/Pkg:\t\t");
642 switch (status.line_prot)
643 {
644 case 0:
645 printf("NotSet/");
646 break;

--- 43 unchanged lines hidden (view full) ---

690 default:
691 printf("unknown line_pkg: %d\n", status.line_pkg);
692 break;
693 }
694
695 if (status.line_pkg == PKG_SPPP)
696 printf("SPPP Keep-alives:\t%s\n",
697 config.keep_alive ? on : off);
662 }
698}
663
699
664void print_crc_len()
665 {
700static void
701print_crc_len(void)
702{
666 printf("CRC length:\t\t");
667 if (config.crc_len == CFG_CRC_0)
668 printf("no CRC\n");
669 else if (config.crc_len == CFG_CRC_16)
670 printf("16 bits\n");
671 else if (config.crc_len == CFG_CRC_32)
672 printf("32 bits\n");
673 else
674 printf("bad crc_len: %d\n", config.crc_len);
703 printf("CRC length:\t\t");
704 if (config.crc_len == CFG_CRC_0)
705 printf("no CRC\n");
706 else if (config.crc_len == CFG_CRC_16)
707 printf("16 bits\n");
708 else if (config.crc_len == CFG_CRC_32)
709 printf("32 bits\n");
710 else
711 printf("bad crc_len: %d\n", config.crc_len);
675 }
712}
676
713
677void print_loop_back()
678 {
714static void
715print_loop_back(void)
716{
679 printf("Loopback:\t\t");
680 switch (config.loop_back)
681 {
682 case CFG_LOOP_NONE:
683 printf("None\n");
684 break;
685 case CFG_LOOP_PAYLOAD:
686 printf("Outward thru framer (payload loop)\n");

--- 21 unchanged lines hidden (view full) ---

708 break;
709 case CFG_LOOP_RL:
710 printf("LB/RL asserted\n");
711 break;
712 default:
713 printf("unknown loop_back: %d\n", config.loop_back);
714 break;
715 }
717 printf("Loopback:\t\t");
718 switch (config.loop_back)
719 {
720 case CFG_LOOP_NONE:
721 printf("None\n");
722 break;
723 case CFG_LOOP_PAYLOAD:
724 printf("Outward thru framer (payload loop)\n");

--- 21 unchanged lines hidden (view full) ---

746 break;
747 case CFG_LOOP_RL:
748 printf("LB/RL asserted\n");
749 break;
750 default:
751 printf("unknown loop_back: %d\n", config.loop_back);
752 break;
753 }
716 }
754}
717
755
718void print_tx_clk_src()
719 {
756static void
757print_tx_clk_src(void)
758{
720 printf("Tx Clk src:\t\t");
721 switch (config.tx_clk_src)
722 {
723 case CFG_CLKMUX_ST:
724 printf("Tx Clk from modem\n");
725 break;
726 case CFG_CLKMUX_INT:
727 printf("Internal source\n");
728 break;
729 case CFG_CLKMUX_RT:
730 printf("Rx Clk from modem (loop timed)\n");
731 break;
732 case CFG_CLKMUX_EXT:
733 printf("External connector\n");
734 break;
735 default:
736 printf("unknown tx_clk_src: %d\n", config.tx_clk_src);
737 break;
738 }
759 printf("Tx Clk src:\t\t");
760 switch (config.tx_clk_src)
761 {
762 case CFG_CLKMUX_ST:
763 printf("Tx Clk from modem\n");
764 break;
765 case CFG_CLKMUX_INT:
766 printf("Internal source\n");
767 break;
768 case CFG_CLKMUX_RT:
769 printf("Rx Clk from modem (loop timed)\n");
770 break;
771 case CFG_CLKMUX_EXT:
772 printf("External connector\n");
773 break;
774 default:
775 printf("unknown tx_clk_src: %d\n", config.tx_clk_src);
776 break;
777 }
739 }
778}
740
779
741void print_format()
742 {
780static void
781print_format(void)
782{
743 printf("Format-Frame/Code:\t");
744 switch (config.format)
745 {
746 case CFG_FORMAT_T1SF:
747 printf("T1-SF/AMI\n");
748 break;
749 case CFG_FORMAT_T1ESF:
750 printf("T1-ESF/B8ZS\n");

--- 18 unchanged lines hidden (view full) ---

769 break;
770 case CFG_FORMAT_T3M13:
771 printf("T3-M13/B3ZS\n");
772 break;
773 default:
774 printf("unknown format: %d\n", config.format);
775 break;
776 }
783 printf("Format-Frame/Code:\t");
784 switch (config.format)
785 {
786 case CFG_FORMAT_T1SF:
787 printf("T1-SF/AMI\n");
788 break;
789 case CFG_FORMAT_T1ESF:
790 printf("T1-ESF/B8ZS\n");

--- 18 unchanged lines hidden (view full) ---

809 break;
810 case CFG_FORMAT_T3M13:
811 printf("T3-M13/B3ZS\n");
812 break;
813 default:
814 printf("unknown format: %d\n", config.format);
815 break;
816 }
777 }
817}
778
818
779void print_dte_dce()
780 {
819static void
820print_dte_dce(void)
821{
781 printf("DTE or DCE:\t\t");
782 switch(config.dte_dce)
783 {
784 case CFG_DTE:
785 printf("DTE (receiving TxClk)\n");
786 break;
787 case CFG_DCE:
788 printf("DCE (driving TxClk)\n");
789 break;
790 default:
791 printf("unknown dte_dce: %d\n", config.dte_dce);
792 break;
793 }
822 printf("DTE or DCE:\t\t");
823 switch(config.dte_dce)
824 {
825 case CFG_DTE:
826 printf("DTE (receiving TxClk)\n");
827 break;
828 case CFG_DCE:
829 printf("DCE (driving TxClk)\n");
830 break;
831 default:
832 printf("unknown dte_dce: %d\n", config.dte_dce);
833 break;
834 }
794 }
835}
795
836
796void print_synth_freq()
797 {
837static void
838print_synth_freq(void)
839{
798 double Fref = 20e6;
799 double Fout, Fvco;
800
801 /* decode the synthesizer params */
802 Fvco = (Fref * (config.synth.n<<(3*config.synth.v)))/config.synth.m;
803 Fout = Fvco / (1<<(config.synth.x+config.synth.r+config.synth.prescale));
804
805 printf("Synth freq:\t\t%.0f\n", Fout);
840 double Fref = 20e6;
841 double Fout, Fvco;
842
843 /* decode the synthesizer params */
844 Fvco = (Fref * (config.synth.n<<(3*config.synth.v)))/config.synth.m;
845 Fout = Fvco / (1<<(config.synth.x+config.synth.r+config.synth.prescale));
846
847 printf("Synth freq:\t\t%.0f\n", Fout);
806 }
848}
807
849
808void synth_freq(unsigned long target)
809 {
850static void
851synth_freq(unsigned long target)
852{
810 unsigned int n, m, v, x, r;
811 double Fout, Fvco, Ftarg;
812 double newdiff, olddiff;
813 double bestF=0.0, bestV=0.0;
814 unsigned prescale = (target < 50000) ? 9:4;
815
816 Ftarg = target<<prescale;
817 for (n=3; n<=127; n++)

--- 26 unchanged lines hidden (view full) ---

844 bestV = Fvco;
845 }
846 }
847#if 0
848 printf("Fbest=%.0f, Ftarg=%u, Fout=%.0f\n", bestF>>prescale, target, bestF);
849 printf("N=%u, M=%u, V=%u, X=%u, R=%u\n", config.synth.n,
850 config.synth.m, config.synth.v, config.synth.x, config.synth.r);
851#endif
853 unsigned int n, m, v, x, r;
854 double Fout, Fvco, Ftarg;
855 double newdiff, olddiff;
856 double bestF=0.0, bestV=0.0;
857 unsigned prescale = (target < 50000) ? 9:4;
858
859 Ftarg = target<<prescale;
860 for (n=3; n<=127; n++)

--- 26 unchanged lines hidden (view full) ---

887 bestV = Fvco;
888 }
889 }
890#if 0
891 printf("Fbest=%.0f, Ftarg=%u, Fout=%.0f\n", bestF>>prescale, target, bestF);
892 printf("N=%u, M=%u, V=%u, X=%u, R=%u\n", config.synth.n,
893 config.synth.m, config.synth.v, config.synth.x, config.synth.r);
894#endif
852 }
895}
853
896
854void print_cable_len()
855 {
897static void
898print_cable_len(void)
899{
856 printf("Cable length:\t\t%d meters\n", config.cable_len);
900 printf("Cable length:\t\t%d meters\n", config.cable_len);
857 }
901}
858
902
859void print_cable_type()
860 {
903static void
904print_cable_type(void)
905{
861 printf("Cable type:\t\t");
862 if (status.cable_type > 7)
863 printf("unknown cable_type: %d\n", status.cable_type);
864 else
865 printf("%s\n", ssi_cables[status.cable_type]);
906 printf("Cable type:\t\t");
907 if (status.cable_type > 7)
908 printf("unknown cable_type: %d\n", status.cable_type);
909 else
910 printf("%s\n", ssi_cables[status.cable_type]);
866 }
911}
867
912
868void print_time_slots()
869 {
913static void
914print_time_slots(void)
915{
870 printf("TimeSlot [31-0]:\t0x%08X\n", config.time_slots);
916 printf("TimeSlot [31-0]:\t0x%08X\n", config.time_slots);
871 }
917}
872
918
873void print_scrambler()
874 {
919static void
920print_scrambler(void)
921{
875 printf("Scrambler:\t\t");
876 if (config.scrambler == CFG_SCRAM_OFF)
877 printf("off\n");
878 else if (config.scrambler == CFG_SCRAM_DL_KEN)
879 printf("DigLink/Kentrox: X^43+1\n");
880 else if (config.scrambler == CFG_SCRAM_LARS)
881 printf("Larse: X^20+X^17+1 w/28ZS\n");
882 else
883 printf("unknown scrambler: %d\n", config.scrambler);
922 printf("Scrambler:\t\t");
923 if (config.scrambler == CFG_SCRAM_OFF)
924 printf("off\n");
925 else if (config.scrambler == CFG_SCRAM_DL_KEN)
926 printf("DigLink/Kentrox: X^43+1\n");
927 else if (config.scrambler == CFG_SCRAM_LARS)
928 printf("Larse: X^20+X^17+1 w/28ZS\n");
929 else
930 printf("unknown scrambler: %d\n", config.scrambler);
884 }
931}
885
932
886double vga_dbs(u_int8_t vga)
887 {
933static double
934vga_dbs(u_int8_t vga)
935{
888 if (vga < 0x0F) return 0.0;
889 if ((vga >= 0x0F) && (vga <= 0x1B)) return 0.0 + 0.77 * (vga - 0x0F);
890 if ((vga >= 0x1C) && (vga <= 0x33)) return 10.0 + 1.25 * (vga - 0x1C);
891 if ((vga >= 0x34) && (vga <= 0x39)) return 40.0 + 1.67 * (vga - 0x34);
892 if ((vga >= 0x3A) && (vga < 0x3F)) return 50.0 + 2.80 * (vga - 0x3A);
893 return 64.0;
936 if (vga < 0x0F) return 0.0;
937 if ((vga >= 0x0F) && (vga <= 0x1B)) return 0.0 + 0.77 * (vga - 0x0F);
938 if ((vga >= 0x1C) && (vga <= 0x33)) return 10.0 + 1.25 * (vga - 0x1C);
939 if ((vga >= 0x34) && (vga <= 0x39)) return 40.0 + 1.67 * (vga - 0x34);
940 if ((vga >= 0x3A) && (vga < 0x3F)) return 50.0 + 2.80 * (vga - 0x3A);
941 return 64.0;
894 }
942}
895
943
896void print_rx_gain()
897 {
944static void
945print_rx_gain(void)
946{
898 printf("Rx gain max:\t\t");
899
900 if (config.rx_gain == CFG_GAIN_AUTO)
901 printf("auto-set to %02.1f dB\n",
902 vga_dbs(read_framer(Bt8370_VGA_MAX) & 0x3F));
903 else
904 printf("up to %02.1f dB\n", vga_dbs(config.rx_gain));
947 printf("Rx gain max:\t\t");
948
949 if (config.rx_gain == CFG_GAIN_AUTO)
950 printf("auto-set to %02.1f dB\n",
951 vga_dbs(read_framer(Bt8370_VGA_MAX) & 0x3F));
952 else
953 printf("up to %02.1f dB\n", vga_dbs(config.rx_gain));
905 }
954}
906
955
907void print_tx_lbo()
908 {
956static void
957print_tx_lbo(void)
958{
909 u_int8_t saved_lbo = config.tx_lbo;
910
911 printf("LBO = ");
912 if (config.tx_lbo == CFG_LBO_AUTO)
913 {
914 config.tx_lbo = read_framer(Bt8370_TLIU_CR) & 0x30;
915 printf("auto-set to ");
916 }

--- 14 unchanged lines hidden (view full) ---

931 break;
932 default:
933 printf("unknown tx_lbo: %d\n", config.tx_lbo);
934 break;
935 }
936
937 if (saved_lbo == CFG_LBO_AUTO)
938 config.tx_lbo = saved_lbo;
959 u_int8_t saved_lbo = config.tx_lbo;
960
961 printf("LBO = ");
962 if (config.tx_lbo == CFG_LBO_AUTO)
963 {
964 config.tx_lbo = read_framer(Bt8370_TLIU_CR) & 0x30;
965 printf("auto-set to ");
966 }

--- 14 unchanged lines hidden (view full) ---

981 break;
982 default:
983 printf("unknown tx_lbo: %d\n", config.tx_lbo);
984 break;
985 }
986
987 if (saved_lbo == CFG_LBO_AUTO)
988 config.tx_lbo = saved_lbo;
939 }
989}
940
990
941void print_tx_pulse()
942 {
991static void
992print_tx_pulse(void)
993{
943 u_int8_t saved_pulse = config.tx_pulse;
944
945 printf("Tx pulse shape:\t\t");
946 if (config.tx_pulse == CFG_PULSE_AUTO)
947 {
948 config.tx_pulse = read_framer(Bt8370_TLIU_CR) & 0x0E;
949 printf("auto-set to ");
950 }

--- 27 unchanged lines hidden (view full) ---

978 break;
979 default:
980 printf("unknown tx_pulse: %d\n", config.tx_pulse);
981 break;
982 }
983
984 if (saved_pulse == CFG_PULSE_AUTO)
985 config.tx_pulse = saved_pulse;
994 u_int8_t saved_pulse = config.tx_pulse;
995
996 printf("Tx pulse shape:\t\t");
997 if (config.tx_pulse == CFG_PULSE_AUTO)
998 {
999 config.tx_pulse = read_framer(Bt8370_TLIU_CR) & 0x0E;
1000 printf("auto-set to ");
1001 }

--- 27 unchanged lines hidden (view full) ---

1029 break;
1030 default:
1031 printf("unknown tx_pulse: %d\n", config.tx_pulse);
1032 break;
1033 }
1034
1035 if (saved_pulse == CFG_PULSE_AUTO)
1036 config.tx_pulse = saved_pulse;
986 }
1037}
987
1038
988void print_ssi_sigs()
989 {
1039static void
1040print_ssi_sigs(void)
1041{
990 u_int32_t mii16 = status.snmp.ssi.sigs;
991 char *on = "On", *off = "Off";
992
993 printf("Modem signals:\t\tDTR=%s DSR=%s RTS=%s CTS=%s\n",
994 (mii16 & MII16_SSI_DTR) ? on : off,
995 (mii16 & MII16_SSI_DSR) ? on : off,
996 (mii16 & MII16_SSI_RTS) ? on : off,
997 (mii16 & MII16_SSI_CTS) ? on : off);
998 printf("Modem signals:\t\tDCD=%s RI=%s LL=%s RL=%s TM=%s\n",
999 (mii16 & MII16_SSI_DCD) ? on : off,
1000 (mii16 & MII16_SSI_RI) ? on : off,
1001 (mii16 & MII16_SSI_LL) ? on : off,
1002 (mii16 & MII16_SSI_RL) ? on : off,
1003 (mii16 & MII16_SSI_TM) ? on : off);
1042 u_int32_t mii16 = status.snmp.ssi.sigs;
1043 char *on = "On", *off = "Off";
1044
1045 printf("Modem signals:\t\tDTR=%s DSR=%s RTS=%s CTS=%s\n",
1046 (mii16 & MII16_SSI_DTR) ? on : off,
1047 (mii16 & MII16_SSI_DSR) ? on : off,
1048 (mii16 & MII16_SSI_RTS) ? on : off,
1049 (mii16 & MII16_SSI_CTS) ? on : off);
1050 printf("Modem signals:\t\tDCD=%s RI=%s LL=%s RL=%s TM=%s\n",
1051 (mii16 & MII16_SSI_DCD) ? on : off,
1052 (mii16 & MII16_SSI_RI) ? on : off,
1053 (mii16 & MII16_SSI_LL) ? on : off,
1054 (mii16 & MII16_SSI_RL) ? on : off,
1055 (mii16 & MII16_SSI_TM) ? on : off);
1004 }
1056}
1005
1057
1006void print_hssi_sigs()
1007 {
1058static void
1059print_hssi_sigs(void)
1060{
1008 u_int32_t mii16 = status.snmp.hssi.sigs;
1009 char *on = "On", *off = "Off";
1010
1011 printf("Modem signals:\t\tTA=%s CA=%s\n",
1012 (mii16 & MII16_HSSI_TA) ? on : off,
1013 (mii16 & MII16_HSSI_CA) ? on : off);
1014 printf("Modem signals:\t\tLA=%s LB=%s LC=%s TM=%s\n",
1015 (mii16 & MII16_HSSI_LA) ? on : off,
1016 (mii16 & MII16_HSSI_LB) ? on : off,
1017 (mii16 & MII16_HSSI_LC) ? on : off,
1018 (mii16 & MII16_HSSI_TM) ? on : off);
1061 u_int32_t mii16 = status.snmp.hssi.sigs;
1062 char *on = "On", *off = "Off";
1063
1064 printf("Modem signals:\t\tTA=%s CA=%s\n",
1065 (mii16 & MII16_HSSI_TA) ? on : off,
1066 (mii16 & MII16_HSSI_CA) ? on : off);
1067 printf("Modem signals:\t\tLA=%s LB=%s LC=%s TM=%s\n",
1068 (mii16 & MII16_HSSI_LA) ? on : off,
1069 (mii16 & MII16_HSSI_LB) ? on : off,
1070 (mii16 & MII16_HSSI_LC) ? on : off,
1071 (mii16 & MII16_HSSI_TM) ? on : off);
1019 }
1072}
1020
1073
1021void print_events()
1022 {
1074static void
1075print_events(void)
1076{
1023 char *time;
1024 struct timeval tv;
1025 struct timezone tz;
1026
1027 gettimeofday(&tv, &tz);
1028 time = (char *)ctime((time_t *)&tv);
1029 printf("Current time:\t\t%s", time);
1030 if (status.cntrs.reset_time.tv_sec < 1000)
1031 time = "Never\n";
1032 else
1033 time = (char *)ctime((time_t *)&status.cntrs.reset_time.tv_sec);
1034 printf("Cntrs reset:\t\t%s", time);
1035
1077 char *time;
1078 struct timeval tv;
1079 struct timezone tz;
1080
1081 gettimeofday(&tv, &tz);
1082 time = (char *)ctime((time_t *)&tv);
1083 printf("Current time:\t\t%s", time);
1084 if (status.cntrs.reset_time.tv_sec < 1000)
1085 time = "Never\n";
1086 else
1087 time = (char *)ctime((time_t *)&status.cntrs.reset_time.tv_sec);
1088 printf("Cntrs reset:\t\t%s", time);
1089
1036 if (status.cntrs.ibytes) printf("Rx bytes:\t\t%qu\n", status.cntrs.ibytes);
1037 if (status.cntrs.obytes) printf("Tx bytes:\t\t%qu\n", status.cntrs.obytes);
1038 if (status.cntrs.ipackets) printf("Rx packets:\t\t%qu\n", status.cntrs.ipackets);
1039 if (status.cntrs.opackets) printf("Tx packets:\t\t%qu\n", status.cntrs.opackets);
1090 if (status.cntrs.ibytes) printf("Rx bytes:\t\t%ju\n", (uintmax_t)status.cntrs.ibytes);
1091 if (status.cntrs.obytes) printf("Tx bytes:\t\t%ju\n", (uintmax_t)status.cntrs.obytes);
1092 if (status.cntrs.ipackets) printf("Rx packets:\t\t%ju\n", (uintmax_t)status.cntrs.ipackets);
1093 if (status.cntrs.opackets) printf("Tx packets:\t\t%ju\n", (uintmax_t)status.cntrs.opackets);
1040 if (status.cntrs.ierrors) printf("Rx errors:\t\t%u\n", status.cntrs.ierrors);
1041 if (status.cntrs.oerrors) printf("Tx errors:\t\t%u\n", status.cntrs.oerrors);
1042 if (status.cntrs.idiscards) printf("Rx discards:\t\t%u\n", status.cntrs.idiscards);
1043 if (status.cntrs.odiscards) printf("Tx discards:\t\t%u\n", status.cntrs.odiscards);
1044 if (status.cntrs.fifo_over) printf("Rx fifo overruns:\t%u\n", status.cntrs.fifo_over);
1045 if (status.cntrs.fifo_under) printf("Tx fifo underruns:\t%u\n", status.cntrs.fifo_under);
1046 if (status.cntrs.missed) printf("Rx missed:\t\t%u\n", status.cntrs.missed);
1047 if (status.cntrs.overruns) printf("Rx overruns:\t\t%u\n", status.cntrs.overruns);

--- 8 unchanged lines hidden (view full) ---

1056 if (config.debug)
1057 { /* These events are hard to explain and may worry users, */
1058 if (status.cntrs.rxdma) printf("Rx no buffs:\t\t%u\n", status.cntrs.rxdma);
1059 if (status.cntrs.txdma) printf("Tx no descs:\t\t%u\n", status.cntrs.txdma);
1060 if (status.cntrs.lck_watch) printf("Lck watch:\t\t%u\n", status.cntrs.lck_watch);
1061 if (status.cntrs.lck_ioctl) printf("Lck ioctl:\t\t%u\n", status.cntrs.lck_ioctl);
1062 if (status.cntrs.lck_intr) printf("Lck intr:\t\t%u\n", status.cntrs.lck_intr);
1063 }
1094 if (status.cntrs.ierrors) printf("Rx errors:\t\t%u\n", status.cntrs.ierrors);
1095 if (status.cntrs.oerrors) printf("Tx errors:\t\t%u\n", status.cntrs.oerrors);
1096 if (status.cntrs.idiscards) printf("Rx discards:\t\t%u\n", status.cntrs.idiscards);
1097 if (status.cntrs.odiscards) printf("Tx discards:\t\t%u\n", status.cntrs.odiscards);
1098 if (status.cntrs.fifo_over) printf("Rx fifo overruns:\t%u\n", status.cntrs.fifo_over);
1099 if (status.cntrs.fifo_under) printf("Tx fifo underruns:\t%u\n", status.cntrs.fifo_under);
1100 if (status.cntrs.missed) printf("Rx missed:\t\t%u\n", status.cntrs.missed);
1101 if (status.cntrs.overruns) printf("Rx overruns:\t\t%u\n", status.cntrs.overruns);

--- 8 unchanged lines hidden (view full) ---

1110 if (config.debug)
1111 { /* These events are hard to explain and may worry users, */
1112 if (status.cntrs.rxdma) printf("Rx no buffs:\t\t%u\n", status.cntrs.rxdma);
1113 if (status.cntrs.txdma) printf("Tx no descs:\t\t%u\n", status.cntrs.txdma);
1114 if (status.cntrs.lck_watch) printf("Lck watch:\t\t%u\n", status.cntrs.lck_watch);
1115 if (status.cntrs.lck_ioctl) printf("Lck ioctl:\t\t%u\n", status.cntrs.lck_ioctl);
1116 if (status.cntrs.lck_intr) printf("Lck intr:\t\t%u\n", status.cntrs.lck_intr);
1117 }
1064 }
1118}
1065
1119
1066void print_summary()
1067 {
1120static void
1121print_summary(void)
1122{
1068 switch(status.card_type)
1069 {
1070 case TLP_CSID_HSSI:
1071 {
1072 print_card_name();
1073 print_card_type();
1074 print_debug();
1075 print_status();

--- 76 unchanged lines hidden (view full) ---

1152 break;
1153 }
1154 default:
1155 {
1156 printf("%s: Unknown card type: %d\n", ifname, status.card_type);
1157 break;
1158 }
1159 }
1123 switch(status.card_type)
1124 {
1125 case TLP_CSID_HSSI:
1126 {
1127 print_card_name();
1128 print_card_type();
1129 print_debug();
1130 print_status();

--- 76 unchanged lines hidden (view full) ---

1207 break;
1208 }
1209 default:
1210 {
1211 printf("%s: Unknown card type: %d\n", ifname, status.card_type);
1212 break;
1213 }
1214 }
1160 }
1215}
1161
1216
1162char *print_t3_bop(int bop_code)
1163 {
1217static char *
1218print_t3_bop(int bop_code)
1219{
1164 switch(bop_code)
1165 {
1166 case 0x00:
1167 return "far end LOF";
1168 case 0x0E:
1169 return "far end LOS";
1170 case 0x16:
1171 return "far end AIS";
1172 case 0x1A:
1173 return "far end IDL";
1174 case 0x07:
1175 return "Line Loopback activate";
1176 case 0x1C:
1177 return "Line Loopback deactivate";
1178 case 0x1B:
1179 return "Entire DS3 line";
1180 default:
1181 return "Unknown BOP code";
1182 }
1220 switch(bop_code)
1221 {
1222 case 0x00:
1223 return "far end LOF";
1224 case 0x0E:
1225 return "far end LOS";
1226 case 0x16:
1227 return "far end AIS";
1228 case 0x1A:
1229 return "far end IDL";
1230 case 0x07:
1231 return "Line Loopback activate";
1232 case 0x1C:
1233 return "Line Loopback deactivate";
1234 case 0x1B:
1235 return "Entire DS3 line";
1236 default:
1237 return "Unknown BOP code";
1238 }
1183 }
1239}
1184
1240
1185void print_t3_snmp()
1186 {
1241static void
1242print_t3_snmp(void)
1243{
1187 printf("SNMP performance data:\n");
1188 printf(" LCV=%d", status.snmp.t3.lcv);
1189 printf(" LOS=%d", (status.snmp.t3.line & TLINE_LOS) ? 1 : 0);
1190 printf(" PCV=%d", status.snmp.t3.pcv);
1191 printf(" CCV=%d", status.snmp.t3.ccv);
1192 printf(" AIS=%d", (status.snmp.t3.line & TLINE_RX_AIS) ? 1 : 0);
1193 printf(" SEF=%d", (status.snmp.t3.line & T1LINE_SEF) ? 1 : 0);
1194 printf(" OOF=%d", (status.snmp.t3.line & TLINE_LOF) ? 1 : 0);
1195 printf(" FEBE=%d", status.snmp.t3.febe);
1196 printf(" RAI=%d", (status.snmp.t3.line & TLINE_RX_RAI) ? 1 : 0);
1197 printf("\n");
1244 printf("SNMP performance data:\n");
1245 printf(" LCV=%d", status.snmp.t3.lcv);
1246 printf(" LOS=%d", (status.snmp.t3.line & TLINE_LOS) ? 1 : 0);
1247 printf(" PCV=%d", status.snmp.t3.pcv);
1248 printf(" CCV=%d", status.snmp.t3.ccv);
1249 printf(" AIS=%d", (status.snmp.t3.line & TLINE_RX_AIS) ? 1 : 0);
1250 printf(" SEF=%d", (status.snmp.t3.line & T1LINE_SEF) ? 1 : 0);
1251 printf(" OOF=%d", (status.snmp.t3.line & TLINE_LOF) ? 1 : 0);
1252 printf(" FEBE=%d", status.snmp.t3.febe);
1253 printf(" RAI=%d", (status.snmp.t3.line & TLINE_RX_RAI) ? 1 : 0);
1254 printf("\n");
1198 }
1255}
1199
1256
1200void print_t3_dsu()
1201 {
1257static void
1258print_t3_dsu(void)
1259{
1202 char *no = "No", *yes = "Yes";
1203 u_int16_t mii16 = read_mii(16);
1204 u_int8_t ctl1 = read_framer(T3CSR_CTL1);
1205 u_int8_t ctl8 = read_framer(T3CSR_CTL8);
1206 u_int8_t stat9 = read_framer(T3CSR_STAT9);
1207 u_int8_t ctl12 = read_framer(T3CSR_CTL12);
1208 u_int8_t stat16 = read_framer(T3CSR_STAT16);
1209

--- 28 unchanged lines hidden (view full) ---

1238 print_t3_bop(read_framer(T3CSR_TX_FEAC) & 0x3F));
1239 printf("Last dbl FEAC msg;\t0x%02X (%s)\n",
1240 read_framer(T3CSR_DBL_FEAC) & 0x3F,
1241 print_t3_bop(read_framer(T3CSR_DBL_FEAC) & 0x3F));
1242 printf("Last Rx FEAC msg:\t0x%02X (%s)\n",
1243 read_framer(T3CSR_RX_FEAC) & 0x3F,
1244 print_t3_bop(read_framer(T3CSR_RX_FEAC) & 0x3F));
1245 print_t3_snmp();
1260 char *no = "No", *yes = "Yes";
1261 u_int16_t mii16 = read_mii(16);
1262 u_int8_t ctl1 = read_framer(T3CSR_CTL1);
1263 u_int8_t ctl8 = read_framer(T3CSR_CTL8);
1264 u_int8_t stat9 = read_framer(T3CSR_STAT9);
1265 u_int8_t ctl12 = read_framer(T3CSR_CTL12);
1266 u_int8_t stat16 = read_framer(T3CSR_STAT16);
1267

--- 28 unchanged lines hidden (view full) ---

1296 print_t3_bop(read_framer(T3CSR_TX_FEAC) & 0x3F));
1297 printf("Last dbl FEAC msg;\t0x%02X (%s)\n",
1298 read_framer(T3CSR_DBL_FEAC) & 0x3F,
1299 print_t3_bop(read_framer(T3CSR_DBL_FEAC) & 0x3F));
1300 printf("Last Rx FEAC msg:\t0x%02X (%s)\n",
1301 read_framer(T3CSR_RX_FEAC) & 0x3F,
1302 print_t3_bop(read_framer(T3CSR_RX_FEAC) & 0x3F));
1303 print_t3_snmp();
1246 }
1304}
1247
1305
1248void t3_cmd(int argc, char **argv)
1249 {
1306static void
1307t3_cmd(int argc, char **argv)
1308{
1250 int ch;
1251
1252 while ((ch = getopt(argc, argv, "a:A:B:c:de:fF:lLsS:vV:")) != -1)
1253 {
1254 switch (ch)
1255 {
1256 case 'a': /* stop alarms */
1257 {

--- 164 unchanged lines hidden (view full) ---

1422 }
1423 default:
1424 {
1425 printf("Unknown command char: %c\n", ch);
1426 exit(1);
1427 } /* case */
1428 } /* switch */
1429 } /* while */
1309 int ch;
1310
1311 while ((ch = getopt(argc, argv, "a:A:B:c:de:fF:lLsS:vV:")) != -1)
1312 {
1313 switch (ch)
1314 {
1315 case 'a': /* stop alarms */
1316 {

--- 164 unchanged lines hidden (view full) ---

1481 }
1482 default:
1483 {
1484 printf("Unknown command char: %c\n", ch);
1485 exit(1);
1486 } /* case */
1487 } /* switch */
1488 } /* while */
1430 } /* proc */
1489} /* proc */
1431
1490
1432void print_test_pattern(int patt)
1433 {
1491static void
1492print_test_pattern(int patt)
1493{
1434 printf("Test Pattern:\t\t");
1435 switch (patt)
1436 {
1437 case 0:
1438 printf("unframed X^11+X^9+1\n");
1439 break;
1440 case 1:
1441 printf("unframed X^15+X^14+1\n");

--- 36 unchanged lines hidden (view full) ---

1478 break;
1479 case 14:
1480 printf("framed X^20+X^17+1 w/14ZS (QRSS)\n");
1481 break;
1482 case 15:
1483 printf("framed X^23+X^18+1 w/14ZS\n");
1484 break;
1485 }
1494 printf("Test Pattern:\t\t");
1495 switch (patt)
1496 {
1497 case 0:
1498 printf("unframed X^11+X^9+1\n");
1499 break;
1500 case 1:
1501 printf("unframed X^15+X^14+1\n");

--- 36 unchanged lines hidden (view full) ---

1538 break;
1539 case 14:
1540 printf("framed X^20+X^17+1 w/14ZS (QRSS)\n");
1541 break;
1542 case 15:
1543 printf("framed X^23+X^18+1 w/14ZS\n");
1544 break;
1545 }
1486 }
1546}
1487
1547
1488char *print_t1_bop(int bop_code)
1489 {
1548static char *
1549print_t1_bop(int bop_code)
1550{
1490 switch(bop_code)
1491 {
1492 case 0x00:
1493 return "Yellow Alarm (far end LOF)";
1494 case 0x07:
1495 return "Line Loop up";
1496 case 0x1C:
1497 return "Line Loop down";
1498 case 0x0A:
1499 return "Payload Loop up";
1500 case 0x19:
1501 return "Payload Loop down";
1502 case 0x09:
1503 return "Network Loop up";
1504 case 0x12:
1505 return "Network Loop down";
1506 default:
1507 return "Unknown BOP code";
1508 }
1551 switch(bop_code)
1552 {
1553 case 0x00:
1554 return "Yellow Alarm (far end LOF)";
1555 case 0x07:
1556 return "Line Loop up";
1557 case 0x1C:
1558 return "Line Loop down";
1559 case 0x0A:
1560 return "Payload Loop up";
1561 case 0x19:
1562 return "Payload Loop down";
1563 case 0x09:
1564 return "Network Loop up";
1565 case 0x12:
1566 return "Network Loop down";
1567 default:
1568 return "Unknown BOP code";
1569 }
1509 }
1570}
1510
1571
1511void print_far_report(int index)
1512 {
1572static void
1573print_far_report(int index)
1574{
1513 u_int16_t far = status.snmp.t1.prm[index];
1514
1515 printf(" SEQ=%d ", (far & T1PRM_SEQ)>>8);
1516 if (far & T1PRM_G1) printf("CRC=1");
1517 else if (far & T1PRM_G2) printf("CRC=1 to 5");
1518 else if (far & T1PRM_G3) printf("CRC=5 to 10");
1519 else if (far & T1PRM_G4) printf("CRC=10 to 100");
1520 else if (far & T1PRM_G5) printf("CRC=100 to 319");
1521 else if (far & T1PRM_G6) printf("CRC>=320");
1522 else printf("CRC=0");
1523 printf(" SE=%d", (far & T1PRM_SE) ? 1 : 0);
1524 printf(" FE=%d", (far & T1PRM_FE) ? 1 : 0);
1525 printf(" LV=%d", (far & T1PRM_LV) ? 1 : 0);
1526 printf(" SL=%d", (far & T1PRM_SL) ? 1 : 0);
1527 printf(" LB=%d", (far & T1PRM_LB) ? 1 : 0);
1528 printf("\n");
1575 u_int16_t far = status.snmp.t1.prm[index];
1576
1577 printf(" SEQ=%d ", (far & T1PRM_SEQ)>>8);
1578 if (far & T1PRM_G1) printf("CRC=1");
1579 else if (far & T1PRM_G2) printf("CRC=1 to 5");
1580 else if (far & T1PRM_G3) printf("CRC=5 to 10");
1581 else if (far & T1PRM_G4) printf("CRC=10 to 100");
1582 else if (far & T1PRM_G5) printf("CRC=100 to 319");
1583 else if (far & T1PRM_G6) printf("CRC>=320");
1584 else printf("CRC=0");
1585 printf(" SE=%d", (far & T1PRM_SE) ? 1 : 0);
1586 printf(" FE=%d", (far & T1PRM_FE) ? 1 : 0);
1587 printf(" LV=%d", (far & T1PRM_LV) ? 1 : 0);
1588 printf(" SL=%d", (far & T1PRM_SL) ? 1 : 0);
1589 printf(" LB=%d", (far & T1PRM_LB) ? 1 : 0);
1590 printf("\n");
1529 }
1591}
1530
1592
1531void print_t1_snmp()
1532 {
1593static void
1594print_t1_snmp(void)
1595{
1533 printf("SNMP Near-end performance data:\n");
1534 printf(" LCV=%d", status.snmp.t1.lcv);
1535 printf(" LOS=%d", (status.snmp.t1.line & TLINE_LOS) ? 1 : 0);
1536 printf(" FE=%d", status.snmp.t1.fe);
1537 printf(" CRC=%d", status.snmp.t1.crc);
1538 printf(" AIS=%d", (status.snmp.t1.line & TLINE_RX_AIS) ? 1 : 0);
1539 printf(" SEF=%d", (status.snmp.t1.line & T1LINE_SEF) ? 1 : 0);
1540 printf(" OOF=%d", (status.snmp.t1.line & TLINE_LOF) ? 1 : 0);
1541 printf(" RAI=%d",(status.snmp.t1.line & TLINE_RX_RAI) ? 1 : 0);
1542 printf("\n");
1543 if (config.format == CFG_FORMAT_T1ESF)
1544 {
1545 printf("ANSI Far-end performance reports:\n");
1546 print_far_report(0);
1547 print_far_report(1);
1548 print_far_report(2);
1549 print_far_report(3);
1550 }
1596 printf("SNMP Near-end performance data:\n");
1597 printf(" LCV=%d", status.snmp.t1.lcv);
1598 printf(" LOS=%d", (status.snmp.t1.line & TLINE_LOS) ? 1 : 0);
1599 printf(" FE=%d", status.snmp.t1.fe);
1600 printf(" CRC=%d", status.snmp.t1.crc);
1601 printf(" AIS=%d", (status.snmp.t1.line & TLINE_RX_AIS) ? 1 : 0);
1602 printf(" SEF=%d", (status.snmp.t1.line & T1LINE_SEF) ? 1 : 0);
1603 printf(" OOF=%d", (status.snmp.t1.line & TLINE_LOF) ? 1 : 0);
1604 printf(" RAI=%d",(status.snmp.t1.line & TLINE_RX_RAI) ? 1 : 0);
1605 printf("\n");
1606 if (config.format == CFG_FORMAT_T1ESF)
1607 {
1608 printf("ANSI Far-end performance reports:\n");
1609 print_far_report(0);
1610 print_far_report(1);
1611 print_far_report(2);
1612 print_far_report(3);
1613 }
1551 }
1614}
1552
1615
1553void print_t1_dsu()
1554 {
1616static void
1617print_t1_dsu(void)
1618{
1555 char *no = "No", *yes = "Yes";
1556 u_int16_t mii16 = read_mii(16);
1557 u_int8_t isr0 = read_framer(Bt8370_ISR0);
1558 u_int8_t loop = read_framer(Bt8370_LOOP);
1559 u_int8_t vga_max = read_framer(Bt8370_VGA_MAX) & 0x3F;
1560 u_int8_t alm1 = read_framer(Bt8370_ALM1);
1561 u_int8_t alm3 = read_framer(Bt8370_ALM3);
1562 u_int8_t talm = read_framer(Bt8370_TALM);

--- 70 unchanged lines hidden (view full) ---

1633 if (config.format == CFG_FORMAT_T1ESF)
1634 {
1635 printf("Last Tx BOP msg:\t0x%02X (%s)\n",
1636 read_framer(Bt8370_TBOP), print_t1_bop(read_framer(Bt8370_TBOP)));
1637 printf("Last Rx BOP msg:\t0x%02X (%s)\n",
1638 read_framer(Bt8370_RBOP), print_t1_bop(read_framer(Bt8370_RBOP)&0x3F));
1639 }
1640 print_t1_snmp();
1619 char *no = "No", *yes = "Yes";
1620 u_int16_t mii16 = read_mii(16);
1621 u_int8_t isr0 = read_framer(Bt8370_ISR0);
1622 u_int8_t loop = read_framer(Bt8370_LOOP);
1623 u_int8_t vga_max = read_framer(Bt8370_VGA_MAX) & 0x3F;
1624 u_int8_t alm1 = read_framer(Bt8370_ALM1);
1625 u_int8_t alm3 = read_framer(Bt8370_ALM3);
1626 u_int8_t talm = read_framer(Bt8370_TALM);

--- 70 unchanged lines hidden (view full) ---

1697 if (config.format == CFG_FORMAT_T1ESF)
1698 {
1699 printf("Last Tx BOP msg:\t0x%02X (%s)\n",
1700 read_framer(Bt8370_TBOP), print_t1_bop(read_framer(Bt8370_TBOP)));
1701 printf("Last Rx BOP msg:\t0x%02X (%s)\n",
1702 read_framer(Bt8370_RBOP), print_t1_bop(read_framer(Bt8370_RBOP)&0x3F));
1703 }
1704 print_t1_snmp();
1641 }
1705}
1642
1706
1643void t1_cmd(int argc, char **argv)
1644 {
1707static void
1708t1_cmd(int argc, char **argv)
1709{
1645 int ch;
1646
1647 while ((ch = getopt(argc, argv, "a:A:B:c:de:E:fF:g:iIlLpPstT:u:U:vxX")) != -1)
1648 {
1649 switch (ch)
1650 {
1651 case 'a': /* stop alarms */
1652 {

--- 260 unchanged lines hidden (view full) ---

1913 }
1914 default:
1915 {
1916 printf("Unknown command char: %c\n", ch);
1917 exit(1);
1918 } /* case */
1919 } /* switch */
1920 } /* while */
1710 int ch;
1711
1712 while ((ch = getopt(argc, argv, "a:A:B:c:de:E:fF:g:iIlLpPstT:u:U:vxX")) != -1)
1713 {
1714 switch (ch)
1715 {
1716 case 'a': /* stop alarms */
1717 {

--- 260 unchanged lines hidden (view full) ---

1978 }
1979 default:
1980 {
1981 printf("Unknown command char: %c\n", ch);
1982 exit(1);
1983 } /* case */
1984 } /* switch */
1985 } /* while */
1921 } /* proc */
1986} /* proc */
1922
1923/* used when reading Motorola S-Record format ROM files */
1987
1988/* used when reading Motorola S-Record format ROM files */
1924unsigned char read_hex(FILE *f)
1925 {
1989static unsigned char
1990read_hex(FILE *f)
1991{
1926 unsigned char a, b, c;
1927 for (a=0, b=0; a<2; a++)
1928 {
1929 c = fgetc(f);
1930 c -= 48;
1931 if (c > 9) c -= 7;
1932 b = (b<<4) | (c & 0xF);
1933 }
1934 checksum += b;
1935 return b;
1992 unsigned char a, b, c;
1993 for (a=0, b=0; a<2; a++)
1994 {
1995 c = fgetc(f);
1996 c -= 48;
1997 if (c > 9) c -= 7;
1998 b = (b<<4) | (c & 0xF);
1999 }
2000 checksum += b;
2001 return b;
1936 }
2002}
1937
2003
1938static void load_xilinx(char *name)
1939 {
2004static void
2005load_xilinx(char *name)
2006{
1940 FILE *f;
1941 char *ucode;
1942 int i, length;
1943 int c;
1944
1945 if (verbose) printf("Load firmware from file %s...\n", name);
1946 if ((f = fopen(name, "r")) == 0)
1947 {

--- 57 unchanged lines hidden (view full) ---

2005 } /* Motorola S-Record */
2006 else
2007 {
2008 printf("Unknown file type giving up\n");
2009 exit(1);
2010 }
2011
2012 load_xilinx_from_file(ucode, length);
2007 FILE *f;
2008 char *ucode;
2009 int i, length;
2010 int c;
2011
2012 if (verbose) printf("Load firmware from file %s...\n", name);
2013 if ((f = fopen(name, "r")) == 0)
2014 {

--- 57 unchanged lines hidden (view full) ---

2072 } /* Motorola S-Record */
2073 else
2074 {
2075 printf("Unknown file type giving up\n");
2076 exit(1);
2077 }
2078
2079 load_xilinx_from_file(ucode, length);
2013 }
2080}
2014
2015/* 32-bit CRC calculated right-to-left over 8-bit bytes */
2081
2082/* 32-bit CRC calculated right-to-left over 8-bit bytes */
2016u_int32_t crc32(char *bufp, int len)
2017 {
2083static u_int32_t
2084crc32(char *bufp, int len)
2085{
2018 int bit, i;
2019 u_int32_t data;
2020 u_int32_t crc = 0xFFFFFFFFL;
2021 u_int32_t poly = 0xEDB88320L;
2022
2023 for (i = 0; i < len; i++)
2024 for (data = *bufp++, bit = 0; bit < 8; bit++, data >>= 1)
2025 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? poly : 0);
2026
2027 return crc;
2086 int bit, i;
2087 u_int32_t data;
2088 u_int32_t crc = 0xFFFFFFFFL;
2089 u_int32_t poly = 0xEDB88320L;
2090
2091 for (i = 0; i < len; i++)
2092 for (data = *bufp++, bit = 0; bit < 8; bit++, data >>= 1)
2093 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? poly : 0);
2094
2095 return crc;
2028 }
2096}
2029
2030/* 8-bit CRC calculated left-to-right over 16-bit words */
2097
2098/* 8-bit CRC calculated left-to-right over 16-bit words */
2031u_int8_t crc8(u_int16_t *bufp, int len)
2032 {
2099static u_int8_t
2100crc8(u_int16_t *bufp, int len)
2101{
2033 int bit, i;
2034 u_int16_t data;
2035 u_int8_t crc = 0xFF;
2036 u_int8_t poly = 0x07;
2037
2038 for (i = 0; i < len; i++)
2039 for (data = *bufp++, bit = 15; bit >= 0; bit--)
2040 {
2041 if ((i==8) && (bit==7)) break;
2042 crc = (crc << 1) ^ ((((crc >> 7) ^ (data >> bit)) & 1) ? poly : 0);
2043 }
2044 return crc;
2102 int bit, i;
2103 u_int16_t data;
2104 u_int8_t crc = 0xFF;
2105 u_int8_t poly = 0x07;
2106
2107 for (i = 0; i < len; i++)
2108 for (data = *bufp++, bit = 15; bit >= 0; bit--)
2109 {
2110 if ((i==8) && (bit==7)) break;
2111 crc = (crc << 1) ^ ((((crc >> 7) ^ (data >> bit)) & 1) ? poly : 0);
2112 }
2113 return crc;
2045 }
2114}
2046
2047/* HSSI=3, DS3=4, SSI=5, T1E1=6, HSSIc=7, SDSL=8 */
2115
2116/* HSSI=3, DS3=4, SSI=5, T1E1=6, HSSIc=7, SDSL=8 */
2048void init_srom(int board)
2049 {
2117void
2118init_srom(int board)
2119{
2050 int i;
2051 u_int16_t srom[64];
2052
2053 /* zero the entire rom */
2054 for (i=0; i<64; i++) srom[i] = 0;
2055
2056 srom[0] = 0x1376; /* subsys vendor id */
2057 srom[1] = board ? board : (read_mii(3)>>4 & 0xF) +1;

--- 12 unchanged lines hidden (view full) ---

2070 printf(" 0 1 2 3 4 5 6 7 8 9 A B C D E F");
2071 for (i=0; i<64; i++)
2072 {
2073 if (i%8 == 0) printf("\n%02X: ", i<<1);
2074 printf("%02X %02X ", srom[i] & 0xFF, srom[i]>>8);
2075 }
2076 printf("\n\n");
2077#endif
2120 int i;
2121 u_int16_t srom[64];
2122
2123 /* zero the entire rom */
2124 for (i=0; i<64; i++) srom[i] = 0;
2125
2126 srom[0] = 0x1376; /* subsys vendor id */
2127 srom[1] = board ? board : (read_mii(3)>>4 & 0xF) +1;

--- 12 unchanged lines hidden (view full) ---

2140 printf(" 0 1 2 3 4 5 6 7 8 9 A B C D E F");
2141 for (i=0; i<64; i++)
2142 {
2143 if (i%8 == 0) printf("\n%02X: ", i<<1);
2144 printf("%02X %02X ", srom[i] & 0xFF, srom[i]>>8);
2145 }
2146 printf("\n\n");
2147#endif
2078 }
2148}
2079
2149
2080int main(int argc, char **argv)
2081 {
2150int
2151main(int argc, char **argv)
2152{
2082 int i, error, ch;
2083 char *optstring = "13a:bBcCdDeEf:Fhi:L:mM:pP:sS:tT:uUvVwW:xXyYzZ?";
2084
2085 progname = (char *)argv[0];
2086
2087 /* Here is the overall plan:
2088 * 1) Read the interface name from the command line.
2089 * 2) Open the device; decide if netgraph is being used.

--- 386 unchanged lines hidden (view full) ---

2476 } /* while */
2477
2478 if (summary) print_summary();
2479
2480 /* 5) Write the modified interface configuration to the driver. */
2481 if (update) ioctl_write_config();
2482
2483 exit(0);
2153 int i, error, ch;
2154 char *optstring = "13a:bBcCdDeEf:Fhi:L:mM:pP:sS:tT:uUvVwW:xXyYzZ?";
2155
2156 progname = (char *)argv[0];
2157
2158 /* Here is the overall plan:
2159 * 1) Read the interface name from the command line.
2160 * 2) Open the device; decide if netgraph is being used.

--- 386 unchanged lines hidden (view full) ---

2547 } /* while */
2548
2549 if (summary) print_summary();
2550
2551 /* 5) Write the modified interface configuration to the driver. */
2552 if (update) ioctl_write_config();
2553
2554 exit(0);
2484 }
2555}