add tools/chkmoddeps
[dragonfly.git] / sbin / atm / atm / atm_eni.c
blobd6c32a36eb58020abfbf52859b4708ebff9e8338
1 /*
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_eni.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $
27 * @(#) $DragonFly: src/sbin/atm/atm/atm_eni.c,v 1.5 2006/10/16 00:15:35 pavalos Exp $
31 * User configuration and display program
32 * --------------------------------------
34 * Routines for Efficient-specific subcommands
38 #include <sys/param.h>
39 #include <sys/socket.h>
40 #include <net/if.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/hea/eni_stats.h>
50 #include <errno.h>
51 #include <libatm.h>
52 #include <stdio.h>
53 #include <stdlib.h>
54 #include <string.h>
56 #include "atm.h"
59 * Local constants
61 #define SHOW_PHY 1
62 #define SHOW_ATM 2
63 #define SHOW_AAL0 4
64 #define SHOW_AAL5 8
65 #define SHOW_DRIVER 64
69 * Headers for statistics
71 #define ATM_STATS_HDR \
72 "%s ATM Layer Statistics\n\
73 Cells In Cells Out\n"
75 #define AAL0_STATS_HDR \
76 "%s AAL 0 Statistics\n\
77 Cells In Cells Out Cell Drops\n"
79 #define AAL5_STATS_HDR \
80 "%s AAL 5 Statistics\n\
81 CRC/Len CRC Proto PDU\n\
82 Cells In Cells Out Errs Drops PDUs In PDUs Out Errs Errs Drops\n"
84 #define DRIVER_STATS_HDR_1 \
85 "%s Device Driver Statistics\n\
86 Buf Buf Buf Buf Can't VCC VCC No No No RX RX\n\
87 Req No No Alrdy Find PDU Range Resrc RX DMA Queue\n\
88 Size Descr Mem Free Descr Size Error In Bufs Room Full\n"
90 #define DRIVER_STATS_HDR_2 \
91 "%s Device Driver Statistics\n\
92 No ATM No RX No TX Seg Max No No No TX\n\
93 RX IntrQ DMA DMA Not Seg Seg TX Resrc DMA\n\
94 VCC Full Room Addr Align Pad Out Buf Out Room\n"
96 #define OC3_STATS_HDR \
97 "%s OC-3c Statistics\n\
98 Section Path Line Line Path Corr Uncorr\n\
99 BIP8 BIP8 BIP24 FEBE FEBE HCS HCS\n\
100 Errs Errs Errs Errs Errs Errs Errs\n"
103 static void print_eni_oc3(struct air_vinfo_rsp *);
104 static void print_eni_atm(struct air_vinfo_rsp *);
105 static void print_eni_aal0(struct air_vinfo_rsp *);
106 static void print_eni_aal5(struct air_vinfo_rsp *);
107 static void print_eni_driver(struct air_vinfo_rsp *);
110 * Process show ENI statistics command
112 * The statistics printed are vendor-specific, depending on the brand of
113 * the interface card.
115 * Command format:
116 * atm show stats interface [<interface-name> [phy | dev | atm |
117 aal0 | aal5 | driver ]]
119 * Arguments:
120 * intf interface to print statistics for
121 * argc number of remaining arguments to command
122 * argv pointer to remaining argument strings
124 * Returns:
125 * none
128 void
129 show_eni_stats(char *intf, int argc, char **argv)
131 int buf_len, stats_type;
132 struct atminfreq air;
133 struct air_vinfo_rsp *stats;
136 * Get statistics type qualifier
138 if (!strcasecmp("phy", argv[0])) {
139 stats_type = SHOW_PHY;
140 } else if (!strcasecmp("atm", argv[0])) {
141 stats_type = SHOW_ATM;
142 } else if (!strcasecmp("aal0", argv[0])) {
143 stats_type = SHOW_AAL0;
144 } else if (!strcasecmp("aal5", argv[0])) {
145 stats_type = SHOW_AAL5;
146 } else if (!strcasecmp("driver", argv[0])) {
147 stats_type = SHOW_DRIVER;
148 } else {
149 fprintf(stderr, "%s: Illegal or unsupported statistics type\n", prog);
150 exit(1);
152 argc--; argv++;
155 * Get vendor-specific statistics from the kernel
157 UM_ZERO(&air, sizeof(air));
158 air.air_opcode = AIOCS_INF_VST;
159 strcpy(air.air_vinfo_intf, intf);
160 buf_len = do_info_ioctl(&air, sizeof(struct air_vinfo_rsp) + 1024);
161 if (buf_len < 0) {
162 fprintf(stderr, "%s: ", prog);
163 switch (errno) {
164 case ENOPROTOOPT:
165 case EOPNOTSUPP:
166 perror("Internal error");
167 break;
168 case ENXIO:
169 fprintf(stderr, "%s is not an ATM device\n",
170 intf);
171 break;
172 default:
173 perror("ioctl (AIOCINFO)");
174 break;
176 exit(1);
178 stats = (struct air_vinfo_rsp *) air.air_buf_addr;
181 * Print the statistics
183 if ((size_t)buf_len < sizeof(struct air_vinfo_rsp) +
184 sizeof(Eni_stats)) {
185 UM_FREE(stats);
186 return;
189 switch (stats_type) {
190 case SHOW_PHY:
191 print_eni_oc3(stats);
192 break;
193 case SHOW_ATM:
194 print_eni_atm(stats);
195 break;
196 case SHOW_AAL0:
197 print_eni_aal0(stats);
198 break;
199 case SHOW_AAL5:
200 print_eni_aal5(stats);
201 break;
202 case SHOW_DRIVER:
203 print_eni_driver(stats);
204 break;
207 UM_FREE(stats);
212 * Print ENI OC-3c statistics
214 * Arguments:
215 * vi pointer to vendor-specific statistics to print
217 * Returns:
218 * none
221 static void
222 print_eni_oc3(struct air_vinfo_rsp *vi)
224 Eni_stats *stats;
227 * Bump stats pointer past header info
229 stats = (Eni_stats *)
230 ((u_long) vi + sizeof(struct air_vinfo_rsp));
233 * Print a header
235 printf(OC3_STATS_HDR, get_adapter_name(vi->avsp_intf));
238 * Print the OC-3c info
240 printf("%7ld %7ld %7ld %7ld %7ld %7ld %7ld\n",
241 stats->eni_st_oc3.oc3_sect_bip8,
242 stats->eni_st_oc3.oc3_path_bip8,
243 stats->eni_st_oc3.oc3_line_bip24,
244 stats->eni_st_oc3.oc3_line_febe,
245 stats->eni_st_oc3.oc3_path_febe,
246 stats->eni_st_oc3.oc3_hec_corr,
247 stats->eni_st_oc3.oc3_hec_uncorr);
252 * Print ENI ATM statistics
254 * Arguments:
255 * vi pointer to vendor-specific statistics to print
257 * Returns:
258 * none
261 static void
262 print_eni_atm(struct air_vinfo_rsp *vi)
264 Eni_stats *stats;
267 * Bump stats pointer past header info
269 stats = (Eni_stats *)
270 ((u_long) vi + sizeof(struct air_vinfo_rsp));
273 * Print a header
275 printf(ATM_STATS_HDR, get_adapter_name(vi->avsp_intf));
278 * Print the ATM layer info
280 printf("%10ld %10ld\n",
281 stats->eni_st_atm.atm_rcvd,
282 stats->eni_st_atm.atm_xmit);
287 * Print ENI AAL 0 statistics
289 * Arguments:
290 * vi pointer to vendor-specific statistics to print
292 * Returns:
293 * none
296 static void
297 print_eni_aal0(struct air_vinfo_rsp *vi)
299 Eni_stats *stats;
302 * Bump stats pointer past header info
304 stats = (Eni_stats *)
305 ((u_long) vi + sizeof(struct air_vinfo_rsp));
308 * Print a header
310 printf(AAL0_STATS_HDR, get_adapter_name(vi->avsp_intf));
313 * Print the AAL 0 info
315 printf("%10ld %10ld %10ld\n",
316 stats->eni_st_aal0.aal0_rcvd,
317 stats->eni_st_aal0.aal0_xmit,
318 stats->eni_st_aal0.aal0_drops);
323 * Print ENI AAL 5 statistics
325 * Arguments:
326 * vi pointer to vendor-specific statistics to print
328 * Returns:
329 * none
332 static void
333 print_eni_aal5(struct air_vinfo_rsp *vi)
335 Eni_stats *stats;
338 * Bump stats pointer past header info
340 stats = (Eni_stats *)
341 ((u_long) vi + sizeof(struct air_vinfo_rsp));
344 * Print a header
346 printf(AAL5_STATS_HDR, get_adapter_name(vi->avsp_intf));
349 * Print the AAL 5 info
351 printf("%10ld %10ld %5ld %5ld %9ld %9ld %5ld %5ld %5ld\n",
352 stats->eni_st_aal5.aal5_rcvd,
353 stats->eni_st_aal5.aal5_xmit,
354 stats->eni_st_aal5.aal5_crc_len,
355 stats->eni_st_aal5.aal5_drops,
356 stats->eni_st_aal5.aal5_pdu_rcvd,
357 stats->eni_st_aal5.aal5_pdu_xmit,
358 stats->eni_st_aal5.aal5_pdu_crc,
359 stats->eni_st_aal5.aal5_pdu_errs,
360 stats->eni_st_aal5.aal5_pdu_drops);
364 * Print Efficient device driver statistics
366 * Arguments:
367 * vi pointer to vendor-specific statistics to print
369 * Returns:
370 * none
373 static void
374 print_eni_driver(struct air_vinfo_rsp *vi)
376 Eni_stats *stats;
379 * Bump stats pointer past header info
381 stats = (Eni_stats *)
382 ((u_long) vi + sizeof(struct air_vinfo_rsp));
385 * Print 1st header
387 printf(DRIVER_STATS_HDR_1, get_adapter_name(vi->avsp_intf));
390 * Print the driver info
392 printf ( "%5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld\n",
393 stats->eni_st_drv.drv_mm_toobig,
394 stats->eni_st_drv.drv_mm_nodesc,
395 stats->eni_st_drv.drv_mm_nobuf,
396 stats->eni_st_drv.drv_mm_notuse,
397 stats->eni_st_drv.drv_mm_notfnd,
398 stats->eni_st_drv.drv_vc_maxpdu,
399 stats->eni_st_drv.drv_vc_badrng,
400 stats->eni_st_drv.drv_rv_norsc,
401 stats->eni_st_drv.drv_rv_nobufs,
402 stats->eni_st_drv.drv_rv_nodma,
403 stats->eni_st_drv.drv_rv_rxq
407 * Print 2nd header
409 printf(DRIVER_STATS_HDR_2, get_adapter_name(vi->avsp_intf));
412 * Print the driver info
414 printf ( "%5ld %5ld %5ld %5ld %5ld %5ld %5ld %7ld %5ld %7ld\n",
415 stats->eni_st_drv.drv_rv_novcc,
416 stats->eni_st_drv.drv_rv_intrq,
417 stats->eni_st_drv.drv_rv_segdma,
418 stats->eni_st_drv.drv_xm_segdma,
419 stats->eni_st_drv.drv_xm_segnoal,
420 stats->eni_st_drv.drv_xm_seglen,
421 stats->eni_st_drv.drv_xm_maxpdu,
422 stats->eni_st_drv.drv_xm_nobuf,
423 stats->eni_st_drv.drv_xm_norsc,
424 stats->eni_st_drv.drv_xm_nodma