Subversion Repositories HelenOS

Rev

Rev 3886 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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