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