source: mainline/uspace/lib/nic/include/nic_driver.h@ 205f1add

Last change on this file since 205f1add was 205f1add, checked in by Jakub Jermar <jakub@…>, 7 years ago

Get rid of sys/time.h

This commit moves the POSIX-like time functionality from libc's
sys/time.h to libposix and introduces C99-like or HelenOS-specific
interfaces to libc.

Specifically, use of sys/time.h, struct timeval, suseconds_t and
gettimeofday is replaced by time.h (C99), struct timespec (C99),
usec_t (HelenOS) and getuptime / getrealtime (HelenOS).

  • Property mode set to 100644
File size: 7.2 KB
RevLine 
[00d7e1b]1/*
2 * Copyright (c) 2011 Radim Vansa
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/**
30 * @addtogroup libnic
31 * @{
32 */
33/**
34 * @file
35 * @brief Internal NICF structures
36 */
37
38#ifndef __NIC_DRIVER_H__
39#define __NIC_DRIVER_H__
40
41#ifndef LIBNIC_INTERNAL
42#error "This is internal libnic's header, please do not include it"
43#endif
44
45#include <fibril_synch.h>
[cf9cb36]46#include <nic/nic.h>
[00d7e1b]47#include <async.h>
48
49#include "nic.h"
50#include "nic_rx_control.h"
51#include "nic_wol_virtues.h"
52
53struct sw_poll_info {
54 fid_t fibril;
55 volatile int run;
56 volatile int running;
57};
58
59struct nic {
60 /**
61 * Device from device manager's point of view.
62 * The value must be set within the add_device handler
63 * (in nic_create_and_bind) and must not be changed.
64 */
65 ddf_dev_t *dev;
66 /**
67 * Device's NIC function.
68 * The value must be set within the add_device handler
69 * (in nic_driver_register_as_ddf_function) and must not be changed.
70 */
71 ddf_fun_t *fun;
72 /** Current state of the device */
73 nic_device_state_t state;
74 /** Transmiter is busy - messages are dropped */
75 int tx_busy;
76 /** Device's MAC address */
77 nic_address_t mac;
78 /** Device's default MAC address (assigned the first time, used in STOP) */
79 nic_address_t default_mac;
[8d7ec69d]80 /** Client callback session */
81 async_sess_t *client_session;
[00d7e1b]82 /** Current polling mode of the NIC */
83 nic_poll_mode_t poll_mode;
84 /** Polling period (applicable when poll_mode == NIC_POLL_PERIODIC) */
[205f1add]85 struct timespec poll_period;
[00d7e1b]86 /** Current polling mode of the NIC */
87 nic_poll_mode_t default_poll_mode;
88 /** Polling period (applicable when default_poll_mode == NIC_POLL_PERIODIC) */
[205f1add]89 struct timespec default_poll_period;
[00d7e1b]90 /** Software period fibrill information */
91 struct sw_poll_info sw_poll_info;
92 /**
93 * Lock on everything but statistics, rx control and wol virtues. This lock
94 * cannot be used if filters_lock or stats_lock is already held - you must
95 * acquire main_lock first (otherwise deadlock could happen).
96 */
97 fibril_rwlock_t main_lock;
98 /** Device statistics */
99 nic_device_stats_t stats;
100 /**
101 * Lock for statistics. You must not hold any other lock from nic_t except
102 * the main_lock at the same moment. If both this lock and main_lock should
103 * be locked, the main_lock must be locked as the first.
104 */
105 fibril_rwlock_t stats_lock;
106 /** Receive control configuration */
107 nic_rxc_t rx_control;
108 /**
109 * Lock for receive control. You must not hold any other lock from nic_t
110 * except the main_lock at the same moment. If both this lock and main_lock
111 * should be locked, the main_lock must be locked as the first.
112 */
113 fibril_rwlock_t rxc_lock;
114 /** WOL virtues configuration */
115 nic_wol_virtues_t wol_virtues;
116 /**
117 * Lock for WOL virtues. You must not hold any other lock from nic_t
118 * except the main_lock at the same moment. If both this lock and main_lock
119 * should be locked, the main_lock must be locked as the first.
120 */
121 fibril_rwlock_t wv_lock;
122 /**
[1b20da0]123 * Function really sending the data. This MUST be filled in if the
124 * nic_send_message_impl function is used for sending messages (filled
[00d7e1b]125 * as send_message member of the nic_iface_t structure).
126 * Called with the main_lock locked for reading.
127 */
[6d8455d]128 send_frame_handler send_frame;
[00d7e1b]129 /**
130 * Event handler called when device goes to the ACTIVE state.
131 * The implementation is optional.
132 * Called with the main_lock locked for writing.
133 */
134 state_change_handler on_activating;
135 /**
136 * Event handler called when device goes to the DOWN state.
137 * The implementation is optional.
138 * Called with the main_lock locked for writing.
139 */
140 state_change_handler on_going_down;
141 /**
142 * Event handler called when device goes to the STOPPED state.
143 * The implementation is optional.
144 * Called with the main_lock locked for writing.
145 */
146 state_change_handler on_stopping;
147 /**
148 * Event handler called when the unicast receive mode is changed.
149 * The implementation is optional. Called with rxc_lock locked for writing.
150 */
151 unicast_mode_change_handler on_unicast_mode_change;
152 /**
153 * Event handler called when the multicast receive mode is changed.
154 * The implementation is optional. Called with rxc_lock locked for writing.
155 */
156 multicast_mode_change_handler on_multicast_mode_change;
157 /**
158 * Event handler called when the broadcast receive mode is changed.
159 * The implementation is optional. Called with rxc_lock locked for writing.
160 */
161 broadcast_mode_change_handler on_broadcast_mode_change;
162 /**
163 * Event handler called when the blocked sources set is changed.
164 * The implementation is optional. Called with rxc_lock locked for writing.
165 */
166 blocked_sources_change_handler on_blocked_sources_change;
167 /**
168 * Event handler called when the VLAN mask is changed.
169 * The implementation is optional. Called with rxc_lock locked for writing.
170 */
171 vlan_mask_change_handler on_vlan_mask_change;
172 /**
173 * Event handler called when a new WOL virtue is added.
174 * The implementation is optional.
175 * Called with filters_lock locked for writing.
176 */
177 wol_virtue_add_handler on_wol_virtue_add;
178 /**
179 * Event handler called when a WOL virtue is removed.
180 * The implementation is optional.
181 * Called with filters_lock locked for writing.
182 */
183 wol_virtue_remove_handler on_wol_virtue_remove;
184 /**
185 * Event handler called when the polling mode is changed.
186 * The implementation is optional.
187 * Called with main_lock locked for writing.
188 */
189 poll_mode_change_handler on_poll_mode_change;
190 /**
191 * Event handler called when the NIC should poll its buffers for a new frame
192 * (in NIC_POLL_PERIODIC or NIC_POLL_ON_DEMAND) modes.
193 * Called with the main_lock locked for reading.
194 * The implementation is optional.
195 */
196 poll_request_handler on_poll_request;
197 /** Data specific for particular driver */
198 void *specific;
199};
200
201/**
202 * Structure keeping global data
203 */
204typedef struct nic_globals {
205 list_t frame_list_cache;
206 size_t frame_list_cache_size;
207 list_t frame_cache;
208 size_t frame_cache_size;
209 fibril_mutex_t lock;
210} nic_globals_t;
211
212#endif
213
214/** @}
215 */
Note: See TracBrowser for help on using the repository browser.