Rev 3666 | Rev 3846 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3666 | Rev 3685 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2008 Lukas Mejdrech |
2 | * Copyright (c) 2008 Lukas Mejdrech |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
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 |
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. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
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 |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 |
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. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup net |
29 | /** @addtogroup net |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** |
33 | /** |
34 | * @file |
34 | * @file |
35 | */ |
35 | */ |
36 | 36 | ||
37 | #ifndef __NET_NETIF_H__ |
37 | #ifndef __NET_NETIF_H__ |
38 | #define __NET_NETIF_H__ |
38 | #define __NET_NETIF_H__ |
39 | 39 | ||
40 | #include "netif_device_id_type.h" |
40 | #include "netif_device_id_type.h" |
41 | 41 | ||
42 | #define networking_message( ... ) \ |
- | |
43 | if( netif_globals.networking_phone ) ipc_call_sync_3_3( netif_globals.networking_phone, __VA_ARGS__ ) |
- | |
44 | - | ||
45 | #define ll_message( device, message, arg2, arg3, result1, result2, result3 ) \ |
42 | #define ll_message( device, message, arg2, arg3, result1, result2, result3 ) \ |
46 | if(( device )->ll_registered ) async_msg_3(( device )->ll_registered, ( message ), ( device )->device_id, arg2, arg3 ) |
43 | if(( device )->ll_registered >= 0 ) async_msg_3(( device )->ll_registered, ( message ), ( device )->device_id, arg2, arg3 ) |
47 | 44 | ||
48 | typedef enum netif_status{ |
45 | typedef enum netif_state netif_state_t; |
49 | NETIF_NULL = 0, |
- | |
50 | NETIF_STOPPED, |
- | |
51 | NETIF_ACTIVE, |
- | |
52 | NETIF_CARRIER_LOST |
- | |
53 | } netif_status_t; |
- | |
54 | 46 | ||
55 | typedef struct netif_device_stats netif_device_stats_t; |
47 | typedef struct netif_device_stats netif_device_stats_t; |
56 | typedef netif_device_stats_t * netif_device_stats_ref; |
48 | typedef netif_device_stats_t * netif_device_stats_ref; |
57 | typedef struct netif_device netif_device_t; |
49 | typedef struct netif_device netif_device_t; |
58 | typedef netif_device_t * netif_device_ref; |
50 | typedef netif_device_t * netif_device_ref; |
59 | typedef struct netif_globals netif_globals_t; |
51 | typedef struct netif_globals netif_globals_t; |
60 | 52 | ||
61 | DEVICE_MAP_DECLARE( netif_device_map, netif_device_t ); |
53 | DEVICE_MAP_DECLARE( netif_device_map, netif_device_t ); |
62 | 54 | ||
- | 55 | enum netif_state{ |
|
- | 56 | NETIF_NULL = 0, |
|
- | 57 | NETIF_STOPPED, |
|
- | 58 | NETIF_ACTIVE, |
|
- | 59 | NETIF_CARRIER_LOST |
|
- | 60 | }; |
|
- | 61 | ||
63 | // based on linux_kernel/include/linux/netdevice.h |
62 | // based on linux_kernel/include/linux/netdevice.h |
64 | 63 | ||
65 | struct netif_device_stats{ |
64 | struct netif_device_stats{ |
66 | unsigned long rx_packets; /* total packets received */ |
65 | unsigned long rx_packets; /* total packets received */ |
67 | unsigned long tx_packets; /* total packets transmitted */ |
66 | unsigned long tx_packets; /* total packets transmitted */ |
68 | unsigned long rx_bytes; /* total bytes received */ |
67 | unsigned long rx_bytes; /* total bytes received */ |
69 | unsigned long tx_bytes; /* total bytes transmitted */ |
68 | unsigned long tx_bytes; /* total bytes transmitted */ |
70 | unsigned long rx_errors; /* bad packets received */ |
69 | unsigned long rx_errors; /* bad packets received */ |
71 | unsigned long tx_errors; /* packet transmit problems */ |
70 | unsigned long tx_errors; /* packet transmit problems */ |
72 | unsigned long rx_dropped; /* no space in linux buffers */ |
71 | unsigned long rx_dropped; /* no space in linux buffers */ |
73 | unsigned long tx_dropped; /* no space available in linux */ |
72 | unsigned long tx_dropped; /* no space available in linux */ |
74 | unsigned long multicast; /* multicast packets received */ |
73 | unsigned long multicast; /* multicast packets received */ |
75 | unsigned long collisions; |
74 | unsigned long collisions; |
76 | 75 | ||
77 | /* detailed rx_errors: */ |
76 | /* detailed rx_errors: */ |
78 | unsigned long rx_length_errors; |
77 | unsigned long rx_length_errors; |
79 | unsigned long rx_over_errors; /* receiver ring buff overflow */ |
78 | unsigned long rx_over_errors; /* receiver ring buff overflow */ |
80 | unsigned long rx_crc_errors; /* recved pkt with crc error */ |
79 | unsigned long rx_crc_errors; /* recved pkt with crc error */ |
81 | unsigned long rx_frame_errors; /* recv'd frame alignment error */ |
80 | unsigned long rx_frame_errors; /* recv'd frame alignment error */ |
82 | unsigned long rx_fifo_errors; /* recv'r fifo overrun */ |
81 | unsigned long rx_fifo_errors; /* recv'r fifo overrun */ |
83 | unsigned long rx_missed_errors; /* receiver missed packet */ |
82 | unsigned long rx_missed_errors; /* receiver missed packet */ |
84 | 83 | ||
85 | /* detailed tx_errors */ |
84 | /* detailed tx_errors */ |
86 | unsigned long tx_aborted_errors; |
85 | unsigned long tx_aborted_errors; |
87 | unsigned long tx_carrier_errors; |
86 | unsigned long tx_carrier_errors; |
88 | unsigned long tx_fifo_errors; |
87 | unsigned long tx_fifo_errors; |
89 | unsigned long tx_heartbeat_errors; |
88 | unsigned long tx_heartbeat_errors; |
90 | unsigned long tx_window_errors; |
89 | unsigned long tx_window_errors; |
91 | 90 | ||
92 | /* for cslip etc */ |
91 | /* for cslip etc */ |
93 | unsigned long rx_compressed; |
92 | unsigned long rx_compressed; |
94 | unsigned long tx_compressed; |
93 | unsigned long tx_compressed; |
95 | }; |
94 | }; |
96 | 95 | ||
97 | struct netif_device{ |
96 | struct netif_device{ |
98 | netif_device_id_t device_id; |
97 | netif_device_id_t device_id; |
99 | ipc_callid_t ll_registered; |
98 | int ll_registered; |
100 | netif_device_stats_t stats; |
99 | netif_device_stats_t stats; |
101 | netif_status_t status; |
100 | netif_state_t state; |
102 | int flags; |
101 | int flags; |
103 | int mtu; |
102 | size_t mtu; |
- | 103 | void * specific; |
|
104 | }; |
104 | }; |
105 | 105 | ||
106 | struct netif_globals{ |
106 | struct netif_globals{ |
107 | int networking_phone; |
107 | int networking_phone; |
108 | netif_device_map_t netif_device_map; |
108 | netif_device_map_t netif_device_map; |
109 | }; |
109 | }; |
110 | 110 | ||
111 | int netif_device_find( netif_device_id_t device_id, netif_device_ref * device ); |
111 | int netif_device_find( netif_device_id_t device_id, netif_device_ref * device ); |
112 | void netif_device_stats_null( netif_device_stats_ref stats ); |
112 | void netif_device_stats_null( netif_device_stats_ref stats ); |
113 | 113 | ||
114 | #endif |
114 | #endif |
115 | 115 | ||
116 | /** @} |
116 | /** @} |
117 | */ |
117 | */ |
118 | 118 | ||
119 | 119 |