summaryrefslogtreecommitdiffstats
path: root/sbin/atm/atm/atm_eni.c
blob: 8b0627ac8ddceb382b17c668f07d5a3fd57a02c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
/*
 *
 * ===================================
 * HARP  |  Host ATM Research Platform
 * ===================================
 *
 *
 * This Host ATM Research Platform ("HARP") file (the "Software") is
 * made available by Network Computing Services, Inc. ("NetworkCS")
 * "AS IS".  NetworkCS does not provide maintenance, improvements or
 * support of any kind.
 *
 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
 * In no event shall NetworkCS be responsible for any damages, including
 * but not limited to consequential damages, arising from or relating to
 * any use of the Software or related support.
 *
 * Copyright 1994-1998 Network Computing Services, Inc.
 *
 * Copies of this Software may be made, however, the above copyright
 * notice must be reproduced on all copies.
 *
 *	@(#) $FreeBSD$
 *
 */

/*
 * User configuration and display program
 * --------------------------------------
 *
 * Routines for Efficient-specific subcommands
 *
 */

#include <sys/param.h>  
#include <sys/socket.h> 
#include <net/if.h>
#include <netinet/in.h>
#include <netatm/port.h>
#include <netatm/atm.h>
#include <netatm/atm_if.h> 
#include <netatm/atm_sap.h>
#include <netatm/atm_sys.h>
#include <netatm/atm_ioctl.h>
#include <dev/hea/eni_stats.h>

#include <errno.h>
#include <libatm.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "atm.h"

#ifndef lint
__RCSID("@(#) $FreeBSD$");
#endif


/*
 * Local constants
 */
#define	SHOW_PHY	1
#define	SHOW_ATM	2
#define	SHOW_AAL0	4
#define	SHOW_AAL5	8
#define	SHOW_DRIVER	64


/*
 * Headers for statistics
 */
#define ATM_STATS_HDR \
"%s ATM Layer Statistics\n\
  Cells In   Cells Out\n"

#define AAL0_STATS_HDR \
"%s AAL 0 Statistics\n\
  Cells In   Cells Out  Cell Drops\n"

#define AAL5_STATS_HDR \
"%s AAL 5 Statistics\n\
                        CRC/Len                              CRC   Proto  PDU\n\
  Cells In   Cells Out  Errs   Drops    PDUs In   PDUs Out   Errs  Errs   Drops\n"

#define DRIVER_STATS_HDR_1 \
"%s Device Driver Statistics\n\
  Buf    Buf    Buf    Buf  Can't    VCC    VCC     No     No  No RX     RX\n\
  Req     No     No  Alrdy   Find    PDU  Range  Resrc     RX    DMA  Queue\n\
 Size  Descr    Mem   Free  Descr   Size  Error     In   Bufs   Room   Full\n"

#define DRIVER_STATS_HDR_2 \
"%s Device Driver Statistics\n\
   No    ATM  No RX  No TX    Seg           Max       No     No    No TX\n\
   RX  IntrQ    DMA    DMA    Not    Seg    Seg       TX  Resrc      DMA\n\
  VCC   Full   Room   Addr  Align    Pad    Out      Buf    Out     Room\n"

#define OC3_STATS_HDR \
"%s OC-3c Statistics\n\
Section     Path    Line      Line     Path     Corr   Uncorr\n\
BIP8        BIP8    BIP24     FEBE     FEBE     HCS    HCS\n\
Errs        Errs    Errs      Errs     Errs     Errs   Errs\n"


/*
 * Process show ENI statistics command
 *
 * The statistics printed are vendor-specific, depending on the brand of
 * the interface card.
 * 
 * Command format: 
 *	atm show stats interface [<interface-name> [phy | dev | atm |
		aal0 | aal5 | driver ]]
 *
 * Arguments:
 *	intf	interface to print statistics for
 *	argc	number of remaining arguments to command
 *	argv	pointer to remaining argument strings
 *
 * Returns:
 *	none
 *
 */
void
show_eni_stats(intf, argc, argv)
	char		*intf;
	int		argc;
	char		**argv;
{
	int	buf_len, stats_type;
	struct atminfreq	air;
	struct air_vinfo_rsp	*stats;

	/*
	 * Get statistics type qualifier
	 */
	if (!strcasecmp("phy", argv[0])) {
		stats_type = SHOW_PHY;
	} else if (!strcasecmp("atm", argv[0])) {
		stats_type = SHOW_ATM;
	} else if (!strcasecmp("aal0", argv[0])) {
		stats_type = SHOW_AAL0;
	} else if (!strcasecmp("aal5", argv[0])) {
		stats_type = SHOW_AAL5;
	} else if (!strcasecmp("driver", argv[0])) {
		stats_type = SHOW_DRIVER;
	} else {
		fprintf(stderr, "%s: Illegal or unsupported statistics type\n", prog);
		exit(1);
	}
	argc--; argv++;

	/*
	 * Get vendor-specific statistics from the kernel
	 */
	bzero(&air, sizeof(air));
	air.air_opcode = AIOCS_INF_VST;
	strcpy(air.air_vinfo_intf, intf);
	buf_len = do_info_ioctl(&air, sizeof(struct air_vinfo_rsp) + 1024);
	if (buf_len < 0) {
		fprintf(stderr, "%s: ", prog);
		switch (errno) {
		case ENOPROTOOPT:
		case EOPNOTSUPP:
			perror("Internal error");
			break;
		case ENXIO:
			fprintf(stderr, "%s is not an ATM device\n",
					intf);
			break;
		default:
			perror("ioctl (AIOCINFO)");
			break;
		}
		exit(1);
	}
	stats = (struct air_vinfo_rsp *) air.air_buf_addr;

	/*
	 * Print the statistics
	 */
	if (buf_len < sizeof(struct air_vinfo_rsp) +
			sizeof(Eni_stats)) {
		free(stats);
		return;
	}

	switch (stats_type) {
	case SHOW_PHY:
		print_eni_oc3(stats);
		break;
	case SHOW_ATM:
		print_eni_atm(stats);
		break;
	case SHOW_AAL0:
		print_eni_aal0(stats);
		break;
	case SHOW_AAL5:
		print_eni_aal5(stats);
		break;
	case SHOW_DRIVER:
		print_eni_driver(stats);
		break;
	}

	free(stats);
}


/*
 * Print ENI OC-3c statistics
 * 
 * Arguments:
 *	vi	pointer to vendor-specific statistics to print
 *
 * Returns:
 *	none
 *
 */
void
print_eni_oc3(vi)
	struct air_vinfo_rsp	*vi;
{
	Eni_stats	*stats;

	/*
	 * Bump stats pointer past header info
	 */
	stats = (Eni_stats *)
			((u_long) vi + sizeof(struct air_vinfo_rsp));

	/*
	 * Print a header
	 */
	printf(OC3_STATS_HDR, get_adapter_name(vi->avsp_intf));
	
	/*
	 * Print the OC-3c info
	 */
	printf("%7ld  %7ld  %7ld  %7ld  %7ld  %7ld  %7ld\n",
			stats->eni_st_oc3.oc3_sect_bip8,
			stats->eni_st_oc3.oc3_path_bip8,
			stats->eni_st_oc3.oc3_line_bip24,
			stats->eni_st_oc3.oc3_line_febe,
			stats->eni_st_oc3.oc3_path_febe,
			stats->eni_st_oc3.oc3_hec_corr,
			stats->eni_st_oc3.oc3_hec_uncorr);
}


/*
 * Print ENI ATM statistics
 * 
 * Arguments:
 *	vi	pointer to vendor-specific statistics to print
 *
 * Returns:
 *	none
 *
 */
void
print_eni_atm(vi)
	struct air_vinfo_rsp	*vi;
{
	Eni_stats	*stats;

	/*
	 * Bump stats pointer past header info
	 */
	stats = (Eni_stats *)
			((u_long) vi + sizeof(struct air_vinfo_rsp));

	/*
	 * Print a header
	 */
	printf(ATM_STATS_HDR, get_adapter_name(vi->avsp_intf));
	
	/*
	 * Print the ATM layer info
	 */
	printf("%10ld  %10ld\n",
			stats->eni_st_atm.atm_rcvd,
			stats->eni_st_atm.atm_xmit);
}


/*
 * Print ENI AAL 0 statistics
 * 
 * Arguments:
 *	vi	pointer to vendor-specific statistics to print
 *
 * Returns:
 *	none
 *
 */
void
print_eni_aal0(vi)
	struct air_vinfo_rsp	*vi;
{
	Eni_stats	*stats;

	/*
	 * Bump stats pointer past header info
	 */
	stats = (Eni_stats *)
			((u_long) vi + sizeof(struct air_vinfo_rsp));

	/*
	 * Print a header
	 */
	printf(AAL0_STATS_HDR, get_adapter_name(vi->avsp_intf));
	
	/*
	 * Print the AAL 0 info
	 */
	printf("%10ld  %10ld  %10ld\n",
			stats->eni_st_aal0.aal0_rcvd,
			stats->eni_st_aal0.aal0_xmit,
			stats->eni_st_aal0.aal0_drops);
}


/*
 * Print ENI AAL 5 statistics
 * 
 * Arguments:
 *	vi	pointer to vendor-specific statistics to print
 *
 * Returns:
 *	none
 *
 */
void
print_eni_aal5(vi)
	struct air_vinfo_rsp	*vi;
{
	Eni_stats	*stats;

	/*
	 * Bump stats pointer past header info
	 */
	stats = (Eni_stats *)
			((u_long) vi + sizeof(struct air_vinfo_rsp));

	/*
	 * Print a header
	 */
	printf(AAL5_STATS_HDR, get_adapter_name(vi->avsp_intf));
	
	/*
	 * Print the AAL 5 info
	 */
	printf("%10ld  %10ld  %5ld  %5ld  %9ld  %9ld  %5ld  %5ld  %5ld\n",
			stats->eni_st_aal5.aal5_rcvd,
			stats->eni_st_aal5.aal5_xmit,
			stats->eni_st_aal5.aal5_crc_len,
			stats->eni_st_aal5.aal5_drops,
			stats->eni_st_aal5.aal5_pdu_rcvd,
			stats->eni_st_aal5.aal5_pdu_xmit,
			stats->eni_st_aal5.aal5_pdu_crc,
			stats->eni_st_aal5.aal5_pdu_errs,
			stats->eni_st_aal5.aal5_pdu_drops);
}

/*
 * Print Efficient device driver statistics
 *
 * Arguments:
 *      vi      pointer to vendor-specific statistics to print
 *
 * Returns:
 *      none
 *
 */
void
print_eni_driver(vi)
        struct air_vinfo_rsp    *vi;
{
        Eni_stats       *stats;

        /*
         * Bump stats pointer past header info
         */
        stats = (Eni_stats *)
                        ((u_long) vi + sizeof(struct air_vinfo_rsp));

        /*
         * Print 1st header
         */
        printf(DRIVER_STATS_HDR_1, get_adapter_name(vi->avsp_intf));

        /*
         * Print the driver info
         */
        printf ( "%5ld  %5ld  %5ld  %5ld  %5ld  %5ld  %5ld  %5ld  %5ld  %5ld  %5ld\n",
                stats->eni_st_drv.drv_mm_toobig,
                stats->eni_st_drv.drv_mm_nodesc,
                stats->eni_st_drv.drv_mm_nobuf,
                stats->eni_st_drv.drv_mm_notuse,
                stats->eni_st_drv.drv_mm_notfnd,
                stats->eni_st_drv.drv_vc_maxpdu,
                stats->eni_st_drv.drv_vc_badrng,
                stats->eni_st_drv.drv_rv_norsc,
                stats->eni_st_drv.drv_rv_nobufs,
                stats->eni_st_drv.drv_rv_nodma,
                stats->eni_st_drv.drv_rv_rxq
        );

        /*
         * Print 2nd header
         */
        printf(DRIVER_STATS_HDR_2, get_adapter_name(vi->avsp_intf));

        /*
         * Print the driver info
         */
        printf ( "%5ld  %5ld  %5ld  %5ld  %5ld  %5ld  %5ld  %7ld  %5ld  %7ld\n",
                stats->eni_st_drv.drv_rv_novcc,
                stats->eni_st_drv.drv_rv_intrq,
                stats->eni_st_drv.drv_rv_segdma,
                stats->eni_st_drv.drv_xm_segdma,
                stats->eni_st_drv.drv_xm_segnoal,
                stats->eni_st_drv.drv_xm_seglen,
                stats->eni_st_drv.drv_xm_maxpdu,
                stats->eni_st_drv.drv_xm_nobuf,
                stats->eni_st_drv.drv_xm_norsc,
                stats->eni_st_drv.drv_xm_nodma
        );


}

OpenPOWER on IntegriCloud