1 | /*
|
---|
2 | * Copyright (c) 2009 Lukas Mejdrech
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup netif
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 |
|
---|
33 | /** @file
|
---|
34 | * Device identifier, state and usage statistics.
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef __NET_DEVICE_ID_TYPE_H__
|
---|
38 | #define __NET_DEVICE_ID_TYPE_H__
|
---|
39 |
|
---|
40 | #include <adt/int_map.h>
|
---|
41 |
|
---|
42 | /** Device identifier to generic type map declaration.
|
---|
43 | */
|
---|
44 | #define DEVICE_MAP_DECLARE INT_MAP_DECLARE
|
---|
45 |
|
---|
46 | /** Device identifier to generic type map implementation.
|
---|
47 | */
|
---|
48 | #define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT
|
---|
49 |
|
---|
50 | /** Invalid device identifier.
|
---|
51 | */
|
---|
52 | #define DEVICE_INVALID_ID (-1)
|
---|
53 |
|
---|
54 | /** Device identifier type.
|
---|
55 | */
|
---|
56 | typedef int device_id_t;
|
---|
57 |
|
---|
58 | /** Device state type.
|
---|
59 | */
|
---|
60 | typedef enum device_state device_state_t;
|
---|
61 |
|
---|
62 | /** Type definition of the device usage statistics.
|
---|
63 | * @see device_stats
|
---|
64 | */
|
---|
65 | typedef struct device_stats device_stats_t;
|
---|
66 |
|
---|
67 | /** Type definition of the device usage statistics pointer.
|
---|
68 | * @see device_stats
|
---|
69 | */
|
---|
70 | typedef device_stats_t * device_stats_ref;
|
---|
71 |
|
---|
72 | /** Device state.
|
---|
73 | */
|
---|
74 | enum device_state{
|
---|
75 | /** Device not present or not initialized.
|
---|
76 | */
|
---|
77 | NETIF_NULL = 0,
|
---|
78 | /** Device present and stopped.
|
---|
79 | */
|
---|
80 | NETIF_STOPPED,
|
---|
81 | /** Device present and active.
|
---|
82 | */
|
---|
83 | NETIF_ACTIVE,
|
---|
84 | /** Device present but unable to transmit.
|
---|
85 | */
|
---|
86 | NETIF_CARRIER_LOST
|
---|
87 | };
|
---|
88 |
|
---|
89 | /** Device usage statistics.
|
---|
90 | */
|
---|
91 | struct device_stats{
|
---|
92 | /** Total packets received.
|
---|
93 | */
|
---|
94 | unsigned long receive_packets;
|
---|
95 | /** Total packets transmitted.
|
---|
96 | */
|
---|
97 | unsigned long send_packets;
|
---|
98 | /** Total bytes received.
|
---|
99 | */
|
---|
100 | unsigned long receive_bytes;
|
---|
101 | /** Total bytes transmitted.
|
---|
102 | */
|
---|
103 | unsigned long send_bytes;
|
---|
104 | /** Bad packets received counter.
|
---|
105 | */
|
---|
106 | unsigned long receive_errors;
|
---|
107 | /** Packet transmition problems counter.
|
---|
108 | */
|
---|
109 | unsigned long send_errors;
|
---|
110 | /** No space in buffers counter.
|
---|
111 | */
|
---|
112 | unsigned long receive_dropped;
|
---|
113 | /** No space available counter.
|
---|
114 | */
|
---|
115 | unsigned long send_dropped;
|
---|
116 | /** Total multicast packets received.
|
---|
117 | */
|
---|
118 | unsigned long multicast;
|
---|
119 | /** The number of collisions due to congestion on the medium.
|
---|
120 | */
|
---|
121 | unsigned long collisions;
|
---|
122 |
|
---|
123 | /* detailed receive_errors: */
|
---|
124 | /** Received packet length error counter.
|
---|
125 | */
|
---|
126 | unsigned long receive_length_errors;
|
---|
127 | /** Receiver buffer overflow counter.
|
---|
128 | */
|
---|
129 | unsigned long receive_over_errors;
|
---|
130 | /** Received packet with crc error counter.
|
---|
131 | */
|
---|
132 | unsigned long receive_crc_errors;
|
---|
133 | /** Received frame alignment error counter.
|
---|
134 | */
|
---|
135 | unsigned long receive_frame_errors;
|
---|
136 | /** Receiver fifo overrun counter.
|
---|
137 | */
|
---|
138 | unsigned long receive_fifo_errors;
|
---|
139 | /** Receiver missed packet counter.
|
---|
140 | */
|
---|
141 | unsigned long receive_missed_errors;
|
---|
142 |
|
---|
143 | /* detailed send_errors */
|
---|
144 | /** Transmitter aborted counter.
|
---|
145 | */
|
---|
146 | unsigned long send_aborted_errors;
|
---|
147 | /** Transmitter carrier errors counter.
|
---|
148 | */
|
---|
149 | unsigned long send_carrier_errors;
|
---|
150 | /** Transmitter fifo overrun counter.
|
---|
151 | */
|
---|
152 | unsigned long send_fifo_errors;
|
---|
153 | /** Transmitter carrier errors counter.
|
---|
154 | */
|
---|
155 | unsigned long send_heartbeat_errors;
|
---|
156 | /** Transmitter window errors counter.
|
---|
157 | */
|
---|
158 | unsigned long send_window_errors;
|
---|
159 |
|
---|
160 | /* for cslip etc */
|
---|
161 | /** Total compressed packets received.
|
---|
162 | */
|
---|
163 | unsigned long receive_compressed;
|
---|
164 | /** Total compressed packet transmitted.
|
---|
165 | */
|
---|
166 | unsigned long send_compressed;
|
---|
167 | };
|
---|
168 |
|
---|
169 | #endif
|
---|
170 |
|
---|
171 | /** @}
|
---|
172 | */
|
---|
173 |
|
---|