source: mainline/uspace/lib/net/include/netif_local.h@ 995689d1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 995689d1 was e526f08, checked in by Jakub Jermar <jakub@…>, 15 years ago

Move net_device.h to standard library.

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