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