source: mainline/uspace/lib/c/include/net/device.h@ 995689d1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 995689d1 was e526f08, checked in by Jakub Jermar <jakub@…>, 15 years ago

Move net_device.h to standard library.

  • Property mode set to 100644
File size: 4.4 KB
Line 
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 libc
30 * @{
31 */
32
33/** @file
34 * Device identifier, state and usage statistics.
35 */
36
37#ifndef LIBC_DEVICE_ID_TYPE_H_
38#define LIBC_DEVICE_ID_TYPE_H_
39
40#include <adt/int_map.h>
41
42/** Device identifier to generic type map declaration. */
43#define DEVICE_MAP_DECLARE INT_MAP_DECLARE
44
45/** Device identifier to generic type map implementation. */
46#define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT
47
48/** Invalid device identifier. */
49#define DEVICE_INVALID_ID (-1)
50
51/** Device identifier type. */
52typedef int device_id_t;
53
54/** Device state type. */
55typedef enum device_state device_state_t;
56
57/** Type definition of the device usage statistics.
58 * @see device_stats
59 */
60typedef struct device_stats device_stats_t;
61
62/** Type definition of the device usage statistics pointer.
63 * @see device_stats
64 */
65typedef device_stats_t *device_stats_ref;
66
67/** Device state. */
68enum device_state {
69 /** Device not present or not initialized. */
70 NETIF_NULL = 0,
71 /** Device present and stopped. */
72 NETIF_STOPPED,
73 /** Device present and active. */
74 NETIF_ACTIVE,
75 /** Device present but unable to transmit. */
76 NETIF_CARRIER_LOST
77};
78
79/** Device usage statistics. */
80struct device_stats {
81 /** Total packets received. */
82 unsigned long receive_packets;
83 /** Total packets transmitted. */
84 unsigned long send_packets;
85 /** Total bytes received. */
86 unsigned long receive_bytes;
87 /** Total bytes transmitted. */
88 unsigned long send_bytes;
89 /** Bad packets received counter. */
90 unsigned long receive_errors;
91 /** Packet transmition problems counter. */
92 unsigned long send_errors;
93 /** No space in buffers counter. */
94 unsigned long receive_dropped;
95 /** No space available counter. */
96 unsigned long send_dropped;
97 /** Total multicast packets received. */
98 unsigned long multicast;
99 /** The number of collisions due to congestion on the medium. */
100 unsigned long collisions;
101
102 /* detailed receive_errors */
103
104 /** Received packet length error counter. */
105 unsigned long receive_length_errors;
106 /** Receiver buffer overflow counter. */
107 unsigned long receive_over_errors;
108 /** Received packet with crc error counter. */
109 unsigned long receive_crc_errors;
110 /** Received frame alignment error counter. */
111 unsigned long receive_frame_errors;
112 /** Receiver fifo overrun counter. */
113 unsigned long receive_fifo_errors;
114 /** Receiver missed packet counter. */
115 unsigned long receive_missed_errors;
116
117 /* detailed send_errors */
118
119 /** Transmitter aborted counter. */
120 unsigned long send_aborted_errors;
121 /** Transmitter carrier errors counter. */
122 unsigned long send_carrier_errors;
123 /** Transmitter fifo overrun counter. */
124 unsigned long send_fifo_errors;
125 /** Transmitter carrier errors counter. */
126 unsigned long send_heartbeat_errors;
127 /** Transmitter window errors counter. */
128 unsigned long send_window_errors;
129
130 /* for cslip etc */
131
132 /** Total compressed packets received. */
133 unsigned long receive_compressed;
134 /** Total compressed packet transmitted. */
135 unsigned long send_compressed;
136};
137
138#endif
139
140/** @}
141 */
Note: See TracBrowser for help on using the repository browser.