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