source: mainline/uspace/lib/net/include/netif_skel.h@ ee2fa30a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since ee2fa30a was ee2fa30a, checked in by Martin Decky <martin@…>, 14 years ago

undo development effort which was neither finished nor properly debugged yet
(this unbreaks networking once again)

  • Property mode set to 100644
File size: 6.5 KB
Line 
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 libnet
30 * @{
31 */
32
33/** @file
34 * Network interface module skeleton.
35 * The skeleton has to be part of each network interface module.
36 */
37
38#ifndef NET_NETIF_SKEL_H_
39#define NET_NETIF_SKEL_H_
40
41#include <fibril_synch.h>
42#include <ipc/services.h>
43#include <adt/measured_strings.h>
44#include <net/device.h>
45#include <net/packet.h>
46#include <async.h>
47
48/** Network interface device specific data. */
49typedef struct {
50 device_id_t device_id; /**< Device identifier. */
51 device_state_t state; /**< Actual device state. */
52 void *specific; /**< Driver specific data. */
53} netif_device_t;
54
55/** Device map.
56 *
57 * Maps device identifiers to the network interface device specific data.
58 * @see device.h
59 *
60 */
61DEVICE_MAP_DECLARE(netif_device_map, netif_device_t);
62
63/** Network interface module skeleton global data. */
64typedef struct {
65 async_sess_t *sess; /**< Networking module session. */
66 async_sess_t *nil_sess; /**< Network interface layer session. */
67 netif_device_map_t device_map; /**< Device map. */
68 fibril_rwlock_t lock; /**< Safety lock. */
69} netif_globals_t;
70
71extern netif_globals_t netif_globals;
72
73/** Initialize the specific module.
74 *
75 * This function has to be implemented in user code.
76 *
77 */
78extern int netif_initialize(void);
79
80/** Probe the existence of the device.
81 *
82 * This has to be implemented in user code.
83 *
84 * @param[in] device_id Device identifier.
85 * @param[in] irq Device interrupt number.
86 * @param[in] io Device input/output address.
87 *
88 * @return EOK on success.
89 * @return Other error codes as defined for the find_device()
90 * function.
91 * @return Other error codes as defined for the specific module
92 * message implementation.
93 *
94 */
95extern int netif_probe_message(device_id_t device_id, int irq, void *io);
96
97/** Send the packet queue.
98 *
99 * This has to be implemented in user code.
100 *
101 * @param[in] device_id Device identifier.
102 * @param[in] packet Packet queue.
103 * @param[in] sender Sending module service.
104 *
105 * @return EOK on success.
106 * @return EFORWARD if the device is not active (in the
107 * NETIF_ACTIVE state).
108 * @return Other error codes as defined for the find_device()
109 * function.
110 * @return Other error codes as defined for the specific module
111 * message implementation.
112 *
113 */
114extern int netif_send_message(device_id_t device_id, packet_t *packet,
115 services_t sender);
116
117/** Start the device.
118 *
119 * This has to be implemented in user code.
120 *
121 * @param[in] device Device structure.
122 *
123 * @return New network interface state (non-negative values).
124 * @return Other error codes as defined for the find_device()
125 * function.
126 * @return Other error codes as defined for the specific module
127 * message implementation.
128 *
129 */
130extern int netif_start_message(netif_device_t *device);
131
132/** Stop the device.
133 *
134 * This has to be implemented in user code.
135 *
136 * @param[in] device Device structure.
137 *
138 * @return EOK on success.
139 * @return Other error codes as defined for the find_device()
140 * function.
141 * @return Other error codes as defined for the specific module
142 * message implementation.
143 *
144 */
145extern int netif_stop_message(netif_device_t *device);
146
147/** Return the device local hardware address.
148 *
149 * This has to be implemented in user code.
150 *
151 * @param[in] device_id Device identifier.
152 * @param[out] address Device local hardware address.
153 *
154 * @return EOK on success.
155 * @return EBADMEM if the address parameter is NULL.
156 * @return ENOENT if there no such device.
157 * @return Other error codes as defined for the find_device()
158 * function.
159 * @return Other error codes as defined for the specific module
160 * message implementation.
161 *
162 */
163extern int netif_get_addr_message(device_id_t device_id,
164 measured_string_t *address);
165
166/** Process the netif driver specific message.
167 *
168 * This function is called for uncommon messages received by the netif
169 * skeleton. This has to be implemented in user code.
170 *
171 * @param[in] callid Message identifier.
172 * @param[in] call Message.
173 * @param[out] answer Answer.
174 * @param[out] count Number of answer arguments.
175 *
176 * @return EOK on success.
177 * @return ENOTSUP if the message is not known.
178 * @return Other error codes as defined for the specific module
179 * message implementation.
180 *
181 */
182extern int netif_specific_message(ipc_callid_t callid, ipc_call_t *call,
183 ipc_call_t *answer, size_t *count);
184
185/** Return the device usage statistics.
186 *
187 * This has to be implemented in user code.
188 *
189 * @param[in] device_id Device identifier.
190 * @param[out] stats Device usage statistics.
191 *
192 * @return EOK on success.
193 * @return Other error codes as defined for the find_device()
194 * function.
195 * @return Other error codes as defined for the specific module
196 * message implementation.
197 *
198 */
199extern int netif_get_device_stats(device_id_t device_id,
200 device_stats_t *stats);
201
202extern int find_device(device_id_t, netif_device_t **);
203extern void null_device_stats(device_stats_t *);
204extern void netif_pq_release(packet_id_t);
205extern packet_t *netif_packet_get_1(size_t);
206
207extern int netif_module_start(void);
208
209#endif
210
211/** @}
212 */
Note: See TracBrowser for help on using the repository browser.