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

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