| 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. */
|
|---|
| 52 | typedef int device_id_t;
|
|---|
| 53 |
|
|---|
| 54 | /** Device state type. */
|
|---|
| 55 | typedef enum device_state device_state_t;
|
|---|
| 56 |
|
|---|
| 57 | /** Type definition of the device usage statistics.
|
|---|
| 58 | * @see device_stats
|
|---|
| 59 | */
|
|---|
| 60 | typedef struct device_stats device_stats_t;
|
|---|
| 61 |
|
|---|
| 62 | /** Device state. */
|
|---|
| 63 | enum device_state {
|
|---|
| 64 | /** Device not present or not initialized. */
|
|---|
| 65 | NETIF_NULL = 0,
|
|---|
| 66 | /** Device present and stopped. */
|
|---|
| 67 | NETIF_STOPPED,
|
|---|
| 68 | /** Device present and active. */
|
|---|
| 69 | NETIF_ACTIVE,
|
|---|
| 70 | /** Device present but unable to transmit. */
|
|---|
| 71 | NETIF_CARRIER_LOST
|
|---|
| 72 | };
|
|---|
| 73 |
|
|---|
| 74 | /** Device usage statistics. */
|
|---|
| 75 | struct device_stats {
|
|---|
| 76 | /** Total packets received. */
|
|---|
| 77 | unsigned long receive_packets;
|
|---|
| 78 | /** Total packets transmitted. */
|
|---|
| 79 | unsigned long send_packets;
|
|---|
| 80 | /** Total bytes received. */
|
|---|
| 81 | unsigned long receive_bytes;
|
|---|
| 82 | /** Total bytes transmitted. */
|
|---|
| 83 | unsigned long send_bytes;
|
|---|
| 84 | /** Bad packets received counter. */
|
|---|
| 85 | unsigned long receive_errors;
|
|---|
| 86 | /** Packet transmition problems counter. */
|
|---|
| 87 | unsigned long send_errors;
|
|---|
| 88 | /** No space in buffers counter. */
|
|---|
| 89 | unsigned long receive_dropped;
|
|---|
| 90 | /** No space available counter. */
|
|---|
| 91 | unsigned long send_dropped;
|
|---|
| 92 | /** Total multicast packets received. */
|
|---|
| 93 | unsigned long multicast;
|
|---|
| 94 | /** The number of collisions due to congestion on the medium. */
|
|---|
| 95 | unsigned long collisions;
|
|---|
| 96 |
|
|---|
| 97 | /* detailed receive_errors */
|
|---|
| 98 |
|
|---|
| 99 | /** Received packet length error counter. */
|
|---|
| 100 | unsigned long receive_length_errors;
|
|---|
| 101 | /** Receiver buffer overflow counter. */
|
|---|
| 102 | unsigned long receive_over_errors;
|
|---|
| 103 | /** Received packet with crc error counter. */
|
|---|
| 104 | unsigned long receive_crc_errors;
|
|---|
| 105 | /** Received frame alignment error counter. */
|
|---|
| 106 | unsigned long receive_frame_errors;
|
|---|
| 107 | /** Receiver fifo overrun counter. */
|
|---|
| 108 | unsigned long receive_fifo_errors;
|
|---|
| 109 | /** Receiver missed packet counter. */
|
|---|
| 110 | unsigned long receive_missed_errors;
|
|---|
| 111 |
|
|---|
| 112 | /* detailed send_errors */
|
|---|
| 113 |
|
|---|
| 114 | /** Transmitter aborted counter. */
|
|---|
| 115 | unsigned long send_aborted_errors;
|
|---|
| 116 | /** Transmitter carrier errors counter. */
|
|---|
| 117 | unsigned long send_carrier_errors;
|
|---|
| 118 | /** Transmitter fifo overrun counter. */
|
|---|
| 119 | unsigned long send_fifo_errors;
|
|---|
| 120 | /** Transmitter carrier errors counter. */
|
|---|
| 121 | unsigned long send_heartbeat_errors;
|
|---|
| 122 | /** Transmitter window errors counter. */
|
|---|
| 123 | unsigned long send_window_errors;
|
|---|
| 124 |
|
|---|
| 125 | /* for cslip etc */
|
|---|
| 126 |
|
|---|
| 127 | /** Total compressed packets received. */
|
|---|
| 128 | unsigned long receive_compressed;
|
|---|
| 129 | /** Total compressed packet transmitted. */
|
|---|
| 130 | unsigned long send_compressed;
|
|---|
| 131 | };
|
|---|
| 132 |
|
|---|
| 133 | #endif
|
|---|
| 134 |
|
|---|
| 135 | /** @}
|
|---|
| 136 | */
|
|---|