3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
26 * @(#) $FreeBSD: src/sbin/atm/atm/atm_fore200.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $
27 * @(#) $DragonFly: src/sbin/atm/atm/atm_fore200.c,v 1.5 2006/10/16 00:15:35 pavalos Exp $
31 * User configuration and display program
32 * --------------------------------------
34 * Routines for Fore SBA-200-specific subcommands
38 #include <sys/param.h>
39 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <netatm/port.h>
43 #include <netatm/atm.h>
44 #include <netatm/atm_if.h>
45 #include <netatm/atm_sap.h>
46 #include <netatm/atm_sys.h>
47 #include <netatm/atm_ioctl.h>
48 #include <dev/atm/hfa/fore_aali.h>
49 #include <dev/atm/hfa/fore_slave.h>
50 #include <dev/atm/hfa/fore_stats.h>
69 #define SHOW_DRIVER 64
73 * Headers for statistics
75 #define TAXI_STATS_HDR \
76 "%s TAXI Statistics\n\
77 CRC Errs Framing Errs\n"
79 #define DEV_STATS_HDR \
80 "%s Device Statistics\n\
81 Type 1 Type 1 Type 2 Type 2\n\
82 Small Buff Large Buff Small Buff Large Buff Receive Receive\n\
83 Alloc Fail Alloc Fail Alloc Fail Alloc Fail Queue Full Carrier\n"
85 #define ATM_STATS_HDR \
86 "%s ATM Layer Statistics\n\
87 Cells In Cells Out VPI Range VPI NoConn VCI Range VCI NoConn\n"
89 #define AAL0_STATS_HDR \
90 "%s AAL 0 Statistics\n\
91 Cells In Cells Out Cell Drops\n"
93 #define AAL4_STATS_HDR \
94 "%s AAL 4 Statistics\n\
95 CRC Proto Cell PDU PDU\n\
96 Cells In Cells Out Errs Errs Drops PDUs In PDUs Out Errs Drops\n"
98 #define AAL5_STATS_HDR \
99 "%s AAL 5 Statistics\n\
100 CRC/Len CRC Proto PDU\n\
101 Cells In Cells Out Errs Drops PDUs In PDUs Out Errs Errs Drops\n"
103 #define DRIVER_STATS_HDR \
104 "%s Device Driver Statistics\n\
105 No Xmit Max Seg No No No IQ No Cmd No\n\
106 VCC Queue Seg Not Seg DMA VCC No Mbuf Full DMA Queue DMA\n\
107 Out Full Size Align Pad Out In Buff In In Sup Full Cmd\n"
109 #define OC3_STATS_HDR \
110 "%s OC-3c Statistics\n\
111 Section Path Line Line Path Corr Uncorr\n\
112 BIP8 BIP8 BIP24 FEBE FEBE HCS HCS\n\
113 Errs Errs Errs Errs Errs Errs Errs\n"
115 static void print_fore200_taxi(struct air_vinfo_rsp *);
116 static void print_fore200_oc3(struct air_vinfo_rsp *);
117 static void print_fore200_dev(struct air_vinfo_rsp *);
118 static void print_fore200_atm(struct air_vinfo_rsp *);
119 static void print_fore200_aal0(struct air_vinfo_rsp *);
120 static void print_fore200_aal4(struct air_vinfo_rsp *);
121 static void print_fore200_aal5(struct air_vinfo_rsp *);
122 static void print_fore200_driver(struct air_vinfo_rsp *);
125 * Process show Fore SBA-200 statistics command
127 * The statistics printed are vendor-specific, depending on the brand of
128 * the interface card.
131 * atm show stats interface [<interface-name> [phy | dev | atm |
132 * aal0 | aal4 | aal5 | driver]]
135 * intf interface statistics are for
136 * argc number of remaining arguments to command
137 * argv pointer to remaining argument strings
144 show_fore200_stats(char *intf, int argc, char **argv)
146 int buf_len, stats_type;
147 struct air_cfg_rsp *cfg;
148 struct air_vinfo_rsp *stats;
149 struct atminfreq air;
152 * Get statistics type qualifier
154 if (!strcasecmp("phy", argv[0])) {
155 stats_type = SHOW_PHY;
156 } else if (!strcasecmp("dev", argv[0])) {
157 stats_type = SHOW_DEV;
158 } else if (!strcasecmp("atm", argv[0])) {
159 stats_type = SHOW_ATM;
160 } else if (!strcasecmp("aal0", argv[0])) {
161 stats_type = SHOW_AAL0;
162 } else if (!strcasecmp("aal4", argv[0])) {
163 stats_type = SHOW_AAL4;
164 } else if (!strcasecmp("aal5", argv[0])) {
165 stats_type = SHOW_AAL5;
166 } else if (!strcasecmp("driver", argv[0])) {
167 stats_type = SHOW_DRIVER;
169 fprintf(stderr, "%s: Illegal statistics type\n", prog);
175 * Get adapter configuration from the kernel
177 UM_ZERO(&air, sizeof(air));
178 air.air_opcode = AIOCS_INF_CFG;
179 strcpy(air.air_cfg_intf, intf);
180 buf_len = do_info_ioctl(&air, sizeof(struct air_cfg_rsp));
182 fprintf(stderr, "%s: ", prog);
186 perror("Internal error");
189 fprintf(stderr, "%s is not an ATM device\n",
193 perror("ioctl (AIOCINFO)");
198 cfg = (struct air_cfg_rsp *) air.air_buf_addr;
201 * Get vendor-specific statistics from the kernel
203 UM_ZERO(&air, sizeof(air));
204 air.air_opcode = AIOCS_INF_VST;
205 strcpy(air.air_vinfo_intf, intf);
206 buf_len = do_info_ioctl(&air, sizeof(struct air_vinfo_rsp) + 1024);
208 fprintf(stderr, "%s: ", prog);
212 perror("Internal error");
215 fprintf(stderr, "%s is not an ATM device\n",
219 perror("ioctl (AIOCINFO)");
224 stats = (struct air_vinfo_rsp *) air.air_buf_addr;
227 * Print the statistics
229 if ((size_t)buf_len < sizeof(struct air_vinfo_rsp) +
230 sizeof(Fore_stats)) {
236 switch (stats_type) {
238 switch (cfg->acp_media) {
241 print_fore200_taxi(stats);
244 print_fore200_oc3(stats);
253 print_fore200_dev(stats);
256 print_fore200_atm(stats);
259 print_fore200_aal0(stats);
262 print_fore200_aal4(stats);
265 print_fore200_aal5(stats);
268 print_fore200_driver(stats);
278 * Print Fore ASX-200 TAXI statistics
281 * vi pointer to vendor-specific statistics to print
288 print_fore200_taxi(struct air_vinfo_rsp *vi)
293 * Bump stats pointer past header info
295 stats = (Fore_stats *)
296 ((u_long) vi + sizeof(struct air_vinfo_rsp));
301 printf(TAXI_STATS_HDR, get_adapter_name(vi->avsp_intf));
304 * Print the physical layer info
306 printf("%10ld %12ld\n",
307 stats->st_taxi.taxi_bad_crc,
308 stats->st_taxi.taxi_framing);
313 * Print Fore ASX-200 OC-3c statistics
316 * vi pointer to vendor-specific statistics to print
323 print_fore200_oc3(struct air_vinfo_rsp *vi)
328 * Bump stats pointer past header info
330 stats = (Fore_stats *)
331 ((u_long) vi + sizeof(struct air_vinfo_rsp));
336 printf(OC3_STATS_HDR, get_adapter_name(vi->avsp_intf));
339 * Print the OC-3c info
341 printf("%7ld %7ld %7ld %7ld %7ld %7ld %7ld\n",
342 stats->st_oc3.oc3_sect_bip8,
343 stats->st_oc3.oc3_path_bip8,
344 stats->st_oc3.oc3_line_bip24,
345 stats->st_oc3.oc3_line_febe,
346 stats->st_oc3.oc3_path_febe,
347 stats->st_oc3.oc3_hec_corr,
348 stats->st_oc3.oc3_hec_uncorr);
353 * Print Fore ASX-200 device statistics
356 * vi pointer to vendor-specific statistics to print
363 print_fore200_dev(struct air_vinfo_rsp *vi)
368 * Bump stats pointer past header info
370 stats = (Fore_stats *)
371 ((u_long) vi + sizeof(struct air_vinfo_rsp));
376 printf(DEV_STATS_HDR, get_adapter_name(vi->avsp_intf));
379 * Print the device info
381 printf("%10ld %10ld %10ld %10ld %10ld %s\n",
382 stats->st_misc.buf1_sm_fail,
383 stats->st_misc.buf1_lg_fail,
384 stats->st_misc.buf2_sm_fail,
385 stats->st_misc.buf2_lg_fail,
386 stats->st_misc.rcvd_pdu_fail,
387 (stats->st_misc.carrier_status ? "On" : "Off"));
392 * Print Fore ASX-200 ATM statistics
395 * vi pointer to vendor-specific statistics to print
402 print_fore200_atm(struct air_vinfo_rsp *vi)
407 * Bump stats pointer past header info
409 stats = (Fore_stats *)
410 ((u_long) vi + sizeof(struct air_vinfo_rsp));
415 printf(ATM_STATS_HDR, get_adapter_name(vi->avsp_intf));
418 * Print the ATM layer info
420 printf("%10ld %10ld %10ld %10ld %10ld %10ld\n",
421 stats->st_atm.atm_rcvd,
422 stats->st_atm.atm_xmit,
423 stats->st_atm.atm_vpi_range,
424 stats->st_atm.atm_vpi_noconn,
425 stats->st_atm.atm_vci_range,
426 stats->st_atm.atm_vci_noconn);
431 * Print Fore ASX-200 AAL 0 statistics
434 * vi pointer to vendor-specific statistics to print
441 print_fore200_aal0(struct air_vinfo_rsp *vi)
446 * Bump stats pointer past header info
448 stats = (Fore_stats *)
449 ((u_long) vi + sizeof(struct air_vinfo_rsp));
454 printf(AAL0_STATS_HDR, get_adapter_name(vi->avsp_intf));
457 * Print the AAL 0 info
459 printf("%10ld %10ld %10ld\n",
460 stats->st_aal0.aal0_rcvd,
461 stats->st_aal0.aal0_xmit,
462 stats->st_aal0.aal0_drops);
467 * Print Fore ASX-200 AAL 4 statistics
470 * vi pointer to vendor-specific statistics to print
477 print_fore200_aal4(struct air_vinfo_rsp *vi)
482 * Bump stats pointer past header info
484 stats = (Fore_stats *)
485 ((u_long) vi + sizeof(struct air_vinfo_rsp));
490 printf(AAL4_STATS_HDR, get_adapter_name(vi->avsp_intf));
493 * Print the AAL 4 info
495 printf("%10ld %10ld %5ld %5ld %5ld %9ld %9ld %5ld %5ld\n",
496 stats->st_aal4.aal4_rcvd,
497 stats->st_aal4.aal4_xmit,
498 stats->st_aal4.aal4_crc,
499 stats->st_aal4.aal4_sar_cs,
500 stats->st_aal4.aal4_drops,
501 stats->st_aal4.aal4_pdu_rcvd,
502 stats->st_aal4.aal4_pdu_xmit,
503 stats->st_aal4.aal4_pdu_errs,
504 stats->st_aal4.aal4_pdu_drops);
509 * Print Fore ASX-200 AAL 5 statistics
512 * vi pointer to vendor-specific statistics to print
519 print_fore200_aal5(struct air_vinfo_rsp *vi)
524 * Bump stats pointer past header info
526 stats = (Fore_stats *)
527 ((u_long) vi + sizeof(struct air_vinfo_rsp));
532 printf(AAL5_STATS_HDR, get_adapter_name(vi->avsp_intf));
535 * Print the AAL 5 info
537 printf("%10ld %10ld %5ld %5ld %9ld %9ld %5ld %5ld %5ld\n",
538 stats->st_aal5.aal5_rcvd,
539 stats->st_aal5.aal5_xmit,
540 stats->st_aal5.aal5_crc_len,
541 stats->st_aal5.aal5_drops,
542 stats->st_aal5.aal5_pdu_rcvd,
543 stats->st_aal5.aal5_pdu_xmit,
544 stats->st_aal5.aal5_pdu_crc,
545 stats->st_aal5.aal5_pdu_errs,
546 stats->st_aal5.aal5_pdu_drops);
551 * Print Fore ASX-200 device driver statistics
554 * vi pointer to vendor-specific statistics to print
561 print_fore200_driver(struct air_vinfo_rsp *vi)
566 * Bump stats pointer past header info
568 stats = (Fore_stats *)
569 ((u_long) vi + sizeof(struct air_vinfo_rsp));
574 printf(DRIVER_STATS_HDR, get_adapter_name(vi->avsp_intf));
577 * Print the driver info
579 printf("%4ld %4ld %4ld %4ld %4ld %4ld %4ld %4ld %4ld %4ld %4ld %4ld %4ld\n",
580 stats->st_drv.drv_xm_notact,
581 stats->st_drv.drv_xm_full,
582 stats->st_drv.drv_xm_maxpdu,
583 stats->st_drv.drv_xm_segnoal,
584 stats->st_drv.drv_xm_seglen,
585 stats->st_drv.drv_xm_segdma,
586 stats->st_drv.drv_rv_novcc,
587 stats->st_drv.drv_rv_nosbf,
588 stats->st_drv.drv_rv_nomb,
589 stats->st_drv.drv_rv_ifull,
590 stats->st_drv.drv_bf_segdma,
591 stats->st_drv.drv_cm_full,
592 stats->st_drv.drv_cm_nodma);