Subversion Repositories HelenOS

Rev

Rev 3991 | Rev 4350 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3991 Rev 4243
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
#define DEVICE_MAP_DECLARE  INT_MAP_DECLARE
42
#define DEVICE_MAP_DECLARE  INT_MAP_DECLARE
43
#define DEVICE_MAP_IMPLEMENT    INT_MAP_IMPLEMENT
43
#define DEVICE_MAP_IMPLEMENT    INT_MAP_IMPLEMENT
44
 
44
 
45
/** Device identifier type.
45
/** Device identifier type.
46
 */
46
 */
47
typedef int device_id_t;
47
typedef int device_id_t;
48
 
48
 
49
/** Device state type.
49
/** Device state type.
50
 */
50
 */
51
typedef enum device_state   device_state_t;
51
typedef enum device_state   device_state_t;
52
 
52
 
53
/** Type definition of the device usage statistics.
53
/** Type definition of the device usage statistics.
54
 *  @see device_stats
54
 *  @see device_stats
55
 */
55
 */
56
typedef struct device_stats device_stats_t;
56
typedef struct device_stats device_stats_t;
57
 
57
 
58
/** Type definition of the device usage statistics pointer.
58
/** Type definition of the device usage statistics pointer.
59
 *  @see device_stats
59
 *  @see device_stats
60
 */
60
 */
61
typedef device_stats_t *    device_stats_ref;
61
typedef device_stats_t *    device_stats_ref;
62
 
62
 
63
/** Device state.
63
/** Device state.
64
 */
64
 */
65
enum    device_state{
65
enum    device_state{
66
    /** Device not present or not initialized.
66
    /** Device not present or not initialized.
67
     */
67
     */
68
    NETIF_NULL = 0,
68
    NETIF_NULL = 0,
69
    /** Device present and stopped.
69
    /** Device present and stopped.
70
     */
70
     */
71
    NETIF_STOPPED,
71
    NETIF_STOPPED,
72
    /** Device present and active.
72
    /** Device present and active.
73
     */
73
     */
74
    NETIF_ACTIVE,
74
    NETIF_ACTIVE,
75
    /** Device present but unable to transmit.
75
    /** Device present but unable to transmit.
76
     */
76
     */
77
    NETIF_CARRIER_LOST
77
    NETIF_CARRIER_LOST
78
};
78
};
79
 
79
 
80
/** \todo
80
/** \todo
81
 */
81
 */
82
#define NIFF_UP         ( 1 << 0 )
82
#define NIFF_UP         ( 1 << 0 )
83
#define NIFF_NOARP      ( 1 << 1 )
83
#define NIFF_NOARP      ( 1 << 1 )
84
#define NIFF_LOOPBACK   ( 1 << 2 )
84
#define NIFF_LOOPBACK   ( 1 << 2 )
85
#define NIFF_BROADCAST  ( 1 << 3 )
85
#define NIFF_BROADCAST  ( 1 << 3 )
86
#define NIFF_PROMISC    ( 1 << 4 )
86
#define NIFF_PROMISC    ( 1 << 4 )
87
#define NIFF_MULTICAST  ( 1 << 5 )
87
#define NIFF_MULTICAST  ( 1 << 5 )
88
 
88
 
89
/** Device usage statistics.
89
/** Device usage statistics.
90
 *  Based on linux_kernel/include/linux/netdevice.h.
90
 *  Based on linux_kernel/include/linux/netdevice.h.
91
 */
91
 */
92
struct  device_stats{
92
struct  device_stats{
93
    /** Total packets received.
93
    /** Total packets received.
94
     */
94
     */
95
    unsigned long   rx_packets;
95
    unsigned long   rx_packets;
96
    /** Total packets transmitted.
96
    /** Total packets transmitted.
97
     */
97
     */
98
    unsigned long   tx_packets;
98
    unsigned long   tx_packets;
99
    /** Total bytes received.
99
    /** Total bytes received.
100
     */
100
     */
101
    unsigned long   rx_bytes;
101
    unsigned long   rx_bytes;
102
    /** Total bytes transmitted.
102
    /** Total bytes transmitted.
103
     */
103
     */
104
    unsigned long   tx_bytes;
104
    unsigned long   tx_bytes;
105
    /** Bad packets received counter.
105
    /** Bad packets received counter.
106
     */
106
     */
107
    unsigned long   rx_errors;
107
    unsigned long   rx_errors;
108
    /** Packet transmition problems counter.
108
    /** Packet transmition problems counter.
109
     */
109
     */
110
    unsigned long   tx_errors;
110
    unsigned long   tx_errors;
111
    /** No space in buffers counter.
111
    /** No space in buffers counter.
112
     */
112
     */
113
    unsigned long   rx_dropped;
113
    unsigned long   rx_dropped;
114
    /** No space available counter.
114
    /** No space available counter.
115
     */
115
     */
116
    unsigned long   tx_dropped;
116
    unsigned long   tx_dropped;
117
    /** Total multicast packets received.
117
    /** Total multicast packets received.
118
     */
118
     */
119
    unsigned long   multicast;
119
    unsigned long   multicast;
120
    /** The number of collisions due to congestion on the medium.
120
    /** The number of collisions due to congestion on the medium.
121
     */
121
     */
122
    unsigned long   collisions;
122
    unsigned long   collisions;
123
 
123
 
124
    /* detailed rx_errors: */
124
    /* detailed rx_errors: */
125
    /** Received packet length error counter.
125
    /** Received packet length error counter.
126
     */
126
     */
127
    unsigned long   rx_length_errors;
127
    unsigned long   rx_length_errors;
128
    /** Receiver buffer overflow counter.
128
    /** Receiver buffer overflow counter.
129
     */
129
     */
130
    unsigned long   rx_over_errors;
130
    unsigned long   rx_over_errors;
131
    /** Received packet with crc error counter.
131
    /** Received packet with crc error counter.
132
     */
132
     */
133
    unsigned long   rx_crc_errors;
133
    unsigned long   rx_crc_errors;
134
    /** Received frame alignment error counter.
134
    /** Received frame alignment error counter.
135
     */
135
     */
136
    unsigned long   rx_frame_errors;
136
    unsigned long   rx_frame_errors;
137
    /** Receiver fifo overrun counter.
137
    /** Receiver fifo overrun counter.
138
     */
138
     */
139
    unsigned long   rx_fifo_errors;
139
    unsigned long   rx_fifo_errors;
140
    /** Receiver missed packet counter.
140
    /** Receiver missed packet counter.
141
     */
141
     */
142
    unsigned long   rx_missed_errors;
142
    unsigned long   rx_missed_errors;
143
 
143
 
144
    /* detailed tx_errors */
144
    /* detailed tx_errors */
145
    /** Transmitter aborted counter.
145
    /** Transmitter aborted counter.
146
     */
146
     */
147
    unsigned long   tx_aborted_errors;
147
    unsigned long   tx_aborted_errors;
148
    /** Transmitter carrier errors counter.
148
    /** Transmitter carrier errors counter.
149
     */
149
     */
150
    unsigned long   tx_carrier_errors;
150
    unsigned long   tx_carrier_errors;
151
    /** Transmitter fifo overrun counter.
151
    /** Transmitter fifo overrun counter.
152
     */
152
     */
153
    unsigned long   tx_fifo_errors;
153
    unsigned long   tx_fifo_errors;
154
    /** Transmitter carrier errors counter.
154
    /** Transmitter carrier errors counter.
155
     */
155
     */
156
    unsigned long   tx_heartbeat_errors;
156
    unsigned long   tx_heartbeat_errors;
157
    /** Transmitter window errors counter.
157
    /** Transmitter window errors counter.
158
     */
158
     */
159
    unsigned long   tx_window_errors;
159
    unsigned long   tx_window_errors;
160
 
160
 
161
    /* for cslip etc */
161
    /* for cslip etc */
162
    /** Total compressed packets received.
162
    /** Total compressed packets received.
163
     */
163
     */
164
    unsigned long   rx_compressed;
164
    unsigned long   rx_compressed;
165
    /** Total compressed packet transmitted.
165
    /** Total compressed packet transmitted.
166
     */
166
     */
167
    unsigned long   tx_compressed;
167
    unsigned long   tx_compressed;
168
};
168
};
169
 
169
 
170
#endif
170
#endif
171
 
171
 
172
/** @}
172
/** @}
173
 */
173
 */
174
 
174
 
175
 
175