]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/atm/atm/atm_fore200.c
This commit was generated by cvs2svn to compensate for changes in r155518,
[FreeBSD/FreeBSD.git] / sbin / atm / atm / atm_fore200.c
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
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.
12  *
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.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  */
26
27 /*
28  * User configuration and display program
29  * --------------------------------------
30  *
31  * Routines for Fore SBA-200-specific subcommands
32  *
33  */
34
35 #include <sys/param.h>  
36 #include <sys/socket.h> 
37 #include <net/if.h>
38 #include <netinet/in.h>
39 #include <netatm/port.h>
40 #include <netatm/atm.h>
41 #include <netatm/atm_if.h> 
42 #include <netatm/atm_sap.h>
43 #include <netatm/atm_sys.h>
44 #include <netatm/atm_ioctl.h>
45 #include <dev/hfa/fore_aali.h>
46 #include <dev/hfa/fore_slave.h>
47 #include <dev/hfa/fore_stats.h>
48
49 #include <errno.h>
50 #include <libatm.h>
51 #include <stdio.h>
52 #include <stdlib.h>
53 #include <string.h>
54 #include <err.h>
55
56 #include "atm.h"
57
58 #ifndef lint
59 __RCSID("@(#) $FreeBSD$");
60 #endif
61
62
63 /*
64  * Local constants
65  */
66 #define SHOW_PHY        1
67 #define SHOW_DEV        2
68 #define SHOW_ATM        4
69 #define SHOW_AAL0       8
70 #define SHOW_AAL4       16
71 #define SHOW_AAL5       32
72 #define SHOW_DRIVER     64
73
74
75 /*
76  * Headers for statistics
77  */
78 #define TAXI_STATS_HDR \
79 "%s TAXI Statistics\n\
80   CRC Errs  Framing Errs\n"
81
82 #define DEV_STATS_HDR \
83 "%s Device Statistics\n\
84 Type 1      Type 1      Type 2      Type 2\n\
85 Small Buff  Large Buff  Small Buff  Large Buff  Receive     Receive\n\
86 Alloc Fail  Alloc Fail  Alloc Fail  Alloc Fail  Queue Full  Carrier\n"
87
88 #define ATM_STATS_HDR \
89 "%s ATM Layer Statistics\n\
90   Cells In   Cells Out   VPI Range  VPI NoConn   VCI Range  VCI NoConn\n"
91
92 #define AAL0_STATS_HDR \
93 "%s AAL 0 Statistics\n\
94   Cells In   Cells Out  Cell Drops\n"
95
96 #define AAL4_STATS_HDR \
97 "%s AAL 4 Statistics\n\
98                          CRC   Proto  Cell                          PDU   PDU\n\
99   Cells In   Cells Out   Errs  Errs   Drops    PDUs In   PDUs Out   Errs  Drops\n"
100
101 #define AAL5_STATS_HDR \
102 "%s AAL 5 Statistics\n\
103                         CRC/Len                              CRC   Proto  PDU\n\
104   Cells In   Cells Out  Errs   Drops    PDUs In   PDUs Out   Errs  Errs   Drops\n"
105
106 #define DRIVER_STATS_HDR \
107 "%s Device Driver Statistics\n\
108   No  Xmit   Max   Seg          No    No          No    IQ    No   Cmd    No\n\
109  VCC Queue   Seg   Not   Seg   DMA   VCC    No  Mbuf  Full   DMA Queue   DMA\n\
110  Out  Full  Size Align   Pad   Out    In  Buff    In    In   Sup  Full   Cmd\n"
111
112 #define OC3_STATS_HDR \
113 "%s OC-3c Statistics\n\
114 Section     Path    Line      Line     Path     Corr   Uncorr\n\
115 BIP8        BIP8    BIP24     FEBE     FEBE     HCS    HCS\n\
116 Errs        Errs    Errs      Errs     Errs     Errs   Errs\n"
117
118 static void     print_fore200_taxi(struct air_vinfo_rsp *);
119 static void     print_fore200_oc3(struct air_vinfo_rsp *);
120 static void     print_fore200_dev(struct air_vinfo_rsp *);
121 static void     print_fore200_atm(struct air_vinfo_rsp *);
122 static void     print_fore200_aal0(struct air_vinfo_rsp *);
123 static void     print_fore200_aal4(struct air_vinfo_rsp *);
124 static void     print_fore200_aal5(struct air_vinfo_rsp *);
125 static void     print_fore200_driver(struct air_vinfo_rsp *);
126
127 /*
128  * Process show Fore SBA-200 statistics command
129  *
130  * The statistics printed are vendor-specific, depending on the brand of
131  * the interface card.
132  * 
133  * Command format: 
134  *      atm show stats interface [<interface-name> [phy | dev | atm |
135  *              aal0 | aal4 | aal5 | driver]]
136  *
137  * Arguments:
138  *      intf    interface statistics are for
139  *      argc    number of remaining arguments to command
140  *      argv    pointer to remaining argument strings
141  *
142  * Returns:
143  *      none
144  *
145  */
146 void
147 show_fore200_stats(intf, argc, argv)
148         char            *intf;
149         int             argc;
150         char            **argv;
151 {
152         int stats_type;
153         ssize_t buf_len;
154         struct air_cfg_rsp      *cfg;
155         struct air_vinfo_rsp    *stats;
156         struct atminfreq        air;
157
158         /*
159          * Get statistics type qualifier
160          */
161         if (!strcasecmp("phy", argv[0])) {
162                 stats_type = SHOW_PHY;
163         } else if (!strcasecmp("dev", argv[0])) {
164                 stats_type = SHOW_DEV;
165         } else if (!strcasecmp("atm", argv[0])) {
166                 stats_type = SHOW_ATM;
167         } else if (!strcasecmp("aal0", argv[0])) {
168                 stats_type = SHOW_AAL0;
169         } else if (!strcasecmp("aal4", argv[0])) {
170                 stats_type = SHOW_AAL4;
171         } else if (!strcasecmp("aal5", argv[0])) {
172                 stats_type = SHOW_AAL5;
173         } else if (!strcasecmp("driver", argv[0])) {
174                 stats_type = SHOW_DRIVER;
175         } else {
176                 errx(1, "Illegal statistics type");
177         }
178         argc--; argv++;
179
180         /*
181          * Get adapter configuration from the kernel
182          */
183         bzero(&air, sizeof(air));
184         air.air_opcode = AIOCS_INF_CFG;
185         strcpy(air.air_cfg_intf, intf);
186         buf_len = do_info_ioctl(&air, sizeof(struct air_cfg_rsp));
187         if (buf_len == -1) {
188                 switch (errno) {
189                 case ENOPROTOOPT:
190                 case EOPNOTSUPP:
191                         err(1, "Internal error");
192                 case ENXIO:
193                         errx(1, "%s is not an ATM device", intf);
194                 default:
195                         err(1, "ioctl (AIOCINFO)");
196                 }
197         }
198         cfg = (struct air_cfg_rsp *)(void *)air.air_buf_addr;
199
200         /*
201          * Get vendor-specific statistics from the kernel
202          */
203         bzero(&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);
207         if (buf_len == -1) {
208                 switch (errno) {
209                 case ENOPROTOOPT:
210                 case EOPNOTSUPP:
211                         err(1, "Internal error");
212                 case ENXIO:
213                         errx(1, "%s is not an ATM device", intf);
214                 default:
215                         err(1, "ioctl (AIOCINFO)");
216                 }
217         }
218         stats = (struct air_vinfo_rsp *)(void *)air.air_buf_addr;
219
220         /*
221          * Print the statistics
222          */
223         if ((size_t)buf_len < sizeof(struct air_vinfo_rsp) +
224                         sizeof(Fore_stats)) {
225                 free(stats);
226                 free(cfg);
227                 return;
228         }
229
230         switch (stats_type) {
231         case SHOW_PHY:
232                 switch (cfg->acp_media) {
233                 case MEDIA_TAXI_100:
234                 case MEDIA_TAXI_140:
235                         print_fore200_taxi(stats);
236                         break;
237                 case MEDIA_OC3C:
238                         print_fore200_oc3(stats);
239                         break;
240                 case MEDIA_OC12C:
241                         break;
242                 default:
243                         break;
244                 }
245                 break;
246         case SHOW_DEV:
247                 print_fore200_dev(stats);
248                 break;
249         case SHOW_ATM:
250                 print_fore200_atm(stats);
251                 break;
252         case SHOW_AAL0:
253                 print_fore200_aal0(stats);
254                 break;
255         case SHOW_AAL4:
256                 print_fore200_aal4(stats);
257                 break;
258         case SHOW_AAL5:
259                 print_fore200_aal5(stats);
260                 break;
261         case SHOW_DRIVER:
262                 print_fore200_driver(stats);
263                 break;
264         }
265
266         free(stats);
267         free(cfg);
268 }
269
270
271 /*
272  * Print Fore ASX-200 TAXI statistics
273  * 
274  * Arguments:
275  *      vi      pointer to vendor-specific statistics to print
276  *
277  * Returns:
278  *      none
279  *
280  */
281 void
282 print_fore200_taxi(vi)
283         struct air_vinfo_rsp    *vi;
284 {
285         Fore_stats      *stats;
286
287         /*
288          * Bump stats pointer past header info
289          */
290         stats = (Fore_stats *) 
291                         ((u_long) vi + sizeof(struct air_vinfo_rsp));
292
293         /*
294          * Print a header
295          */
296         printf(TAXI_STATS_HDR, get_adapter_name(vi->avsp_intf));
297         
298         /*
299          * Print the physical layer info
300          */
301         printf("%10ld  %12ld\n",
302                         stats->st_taxi.taxi_bad_crc,
303                         stats->st_taxi.taxi_framing);
304 }
305
306
307 /*
308  * Print Fore ASX-200 OC-3c statistics
309  * 
310  * Arguments:
311  *      vi      pointer to vendor-specific statistics to print
312  *
313  * Returns:
314  *      none
315  *
316  */
317 void
318 print_fore200_oc3(vi)
319         struct air_vinfo_rsp    *vi;
320 {
321         Fore_stats      *stats;
322
323         /*
324          * Bump stats pointer past header info
325          */
326         stats = (Fore_stats *)
327                         ((u_long) vi + sizeof(struct air_vinfo_rsp));
328
329         /*
330          * Print a header
331          */
332         printf(OC3_STATS_HDR, get_adapter_name(vi->avsp_intf));
333         
334         /*
335          * Print the OC-3c info
336          */
337         printf("%7ld  %7ld  %7ld  %7ld  %7ld  %7ld  %7ld\n",
338                         stats->st_oc3.oc3_sect_bip8,
339                         stats->st_oc3.oc3_path_bip8,
340                         stats->st_oc3.oc3_line_bip24,
341                         stats->st_oc3.oc3_line_febe,
342                         stats->st_oc3.oc3_path_febe,
343                         stats->st_oc3.oc3_hec_corr,
344                         stats->st_oc3.oc3_hec_uncorr);
345 }
346
347
348 /*
349  * Print Fore ASX-200 device statistics
350  * 
351  * Arguments:
352  *      vi      pointer to vendor-specific statistics to print
353  *
354  * Returns:
355  *      none
356  *
357  */
358 void
359 print_fore200_dev(vi)
360         struct air_vinfo_rsp    *vi;
361 {
362         Fore_stats      *stats;
363
364         /*
365          * Bump stats pointer past header info
366          */
367         stats = (Fore_stats *)
368                         ((u_long) vi + sizeof(struct air_vinfo_rsp));
369
370         /*
371          * Print a header
372          */
373         printf(DEV_STATS_HDR, get_adapter_name(vi->avsp_intf));
374         
375         /*
376          * Print the device info
377          */
378         printf("%10ld  %10ld  %10ld  %10ld  %10ld  %s\n",
379                         stats->st_misc.buf1_sm_fail,
380                         stats->st_misc.buf1_lg_fail,
381                         stats->st_misc.buf2_sm_fail,
382                         stats->st_misc.buf2_lg_fail,
383                         stats->st_misc.rcvd_pdu_fail,
384                         (stats->st_misc.carrier_status ? "On" : "Off"));
385 }
386
387
388 /*
389  * Print Fore ASX-200 ATM statistics
390  * 
391  * Arguments:
392  *      vi      pointer to vendor-specific statistics to print
393  *
394  * Returns:
395  *      none
396  *
397  */
398 void
399 print_fore200_atm(vi)
400         struct air_vinfo_rsp    *vi;
401 {
402         Fore_stats      *stats;
403
404         /*
405          * Bump stats pointer past header info
406          */
407         stats = (Fore_stats *)
408                         ((u_long) vi + sizeof(struct air_vinfo_rsp));
409
410         /*
411          * Print a header
412          */
413         printf(ATM_STATS_HDR, get_adapter_name(vi->avsp_intf));
414         
415         /*
416          * Print the ATM layer info
417          */
418         printf("%10ld  %10ld  %10ld  %10ld  %10ld  %10ld\n",
419                         stats->st_atm.atm_rcvd,
420                         stats->st_atm.atm_xmit,
421                         stats->st_atm.atm_vpi_range,
422                         stats->st_atm.atm_vpi_noconn,
423                         stats->st_atm.atm_vci_range,
424                         stats->st_atm.atm_vci_noconn);
425 }
426
427
428 /*
429  * Print Fore ASX-200 AAL 0 statistics
430  * 
431  * Arguments:
432  *      vi      pointer to vendor-specific statistics to print
433  *
434  * Returns:
435  *      none
436  *
437  */
438 void
439 print_fore200_aal0(vi)
440         struct air_vinfo_rsp    *vi;
441 {
442         Fore_stats      *stats;
443
444         /*
445          * Bump stats pointer past header info
446          */
447         stats = (Fore_stats *)
448                         ((u_long) vi + sizeof(struct air_vinfo_rsp));
449
450         /*
451          * Print a header
452          */
453         printf(AAL0_STATS_HDR, get_adapter_name(vi->avsp_intf));
454         
455         /*
456          * Print the AAL 0 info
457          */
458         printf("%10ld  %10ld  %10ld\n",
459                         stats->st_aal0.aal0_rcvd,
460                         stats->st_aal0.aal0_xmit,
461                         stats->st_aal0.aal0_drops);
462 }
463
464
465 /*
466  * Print Fore ASX-200 AAL 4 statistics
467  * 
468  * Arguments:
469  *      vi      pointer to vendor-specific statistics to print
470  *
471  * Returns:
472  *      none
473  *
474  */
475 void
476 print_fore200_aal4(vi)
477         struct air_vinfo_rsp    *vi;
478 {
479         Fore_stats      *stats;
480
481         /*
482          * Bump stats pointer past header info
483          */
484         stats = (Fore_stats *)
485                         ((u_long) vi + sizeof(struct air_vinfo_rsp));
486
487         /*
488          * Print a header
489          */
490         printf(AAL4_STATS_HDR, get_adapter_name(vi->avsp_intf));
491         
492         /*
493          * Print the AAL 4 info
494          */
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);
505 }
506
507
508 /*
509  * Print Fore ASX-200 AAL 5 statistics
510  * 
511  * Arguments:
512  *      vi      pointer to vendor-specific statistics to print
513  *
514  * Returns:
515  *      none
516  *
517  */
518 void
519 print_fore200_aal5(vi)
520         struct air_vinfo_rsp    *vi;
521 {
522         Fore_stats      *stats;
523
524         /*
525          * Bump stats pointer past header info
526          */
527         stats = (Fore_stats *)
528                         ((u_long) vi + sizeof(struct air_vinfo_rsp));
529
530         /*
531          * Print a header
532          */
533         printf(AAL5_STATS_HDR, get_adapter_name(vi->avsp_intf));
534         
535         /*
536          * Print the AAL 5 info
537          */
538         printf("%10ld  %10ld  %5ld  %5ld  %9ld  %9ld  %5ld  %5ld  %5ld\n",
539                         stats->st_aal5.aal5_rcvd,
540                         stats->st_aal5.aal5_xmit,
541                         stats->st_aal5.aal5_crc_len,
542                         stats->st_aal5.aal5_drops,
543                         stats->st_aal5.aal5_pdu_rcvd,
544                         stats->st_aal5.aal5_pdu_xmit,
545                         stats->st_aal5.aal5_pdu_crc,
546                         stats->st_aal5.aal5_pdu_errs,
547                         stats->st_aal5.aal5_pdu_drops);
548 }
549
550
551 /*
552  * Print Fore ASX-200 device driver statistics
553  * 
554  * Arguments:
555  *      vi      pointer to vendor-specific statistics to print
556  *
557  * Returns:
558  *      none
559  *
560  */
561 void
562 print_fore200_driver(vi)
563         struct air_vinfo_rsp    *vi;
564 {
565         Fore_stats      *stats;
566
567         /*
568          * Bump stats pointer past header info
569          */
570         stats = (Fore_stats *)
571                         ((u_long) vi + sizeof(struct air_vinfo_rsp));
572
573         /*
574          * Print a header
575          */
576         printf(DRIVER_STATS_HDR, get_adapter_name(vi->avsp_intf));
577         
578         /*
579          * Print the driver info
580          */
581         printf("%4ld  %4ld  %4ld  %4ld  %4ld  %4ld  %4ld  %4ld  %4ld  %4ld  %4ld  %4ld  %4ld\n",
582                         stats->st_drv.drv_xm_notact,
583                         stats->st_drv.drv_xm_full,
584                         stats->st_drv.drv_xm_maxpdu,
585                         stats->st_drv.drv_xm_segnoal,
586                         stats->st_drv.drv_xm_seglen,
587                         stats->st_drv.drv_xm_segdma,
588                         stats->st_drv.drv_rv_novcc,
589                         stats->st_drv.drv_rv_nosbf,
590                         stats->st_drv.drv_rv_nomb,
591                         stats->st_drv.drv_rv_ifull,
592                         stats->st_drv.drv_bf_segdma,
593                         stats->st_drv.drv_cm_full,
594                         stats->st_drv.drv_cm_nodma);
595
596 }