Xenomai 3.3.2
Loading...
Searching...
No Matches
rtnet_port.h
1/* include/rtnet_port.h
2 *
3 * RTnet - real-time networking subsystem
4 * Copyright (C) 2003 Wittawat Yamwong
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20#ifndef __RTNET_PORT_H_
21#define __RTNET_PORT_H_
22
23#ifdef __KERNEL__
24
25#include <linux/bitops.h>
26#include <linux/moduleparam.h>
27#include <linux/list.h>
28#include <linux/netdevice.h>
29#include <linux/vmalloc.h>
30#include <linux/bitops.h>
31
32#include <rtdev.h>
33#include <rtdev_mgr.h>
34#include <rtdm/driver.h>
35#include <stack_mgr.h>
36#include <ethernet/eth.h>
37
38static inline void rtnetif_start_queue(struct rtnet_device *rtdev)
39{
40 clear_bit(__RTNET_LINK_STATE_XOFF, &rtdev->link_state);
41}
42
43static inline void rtnetif_wake_queue(struct rtnet_device *rtdev)
44{
45 if (test_and_clear_bit(__RTNET_LINK_STATE_XOFF, &rtdev->link_state)) {
46 /*TODO __netif_schedule(dev); */;
47 }
48}
49
50static inline void rtnetif_stop_queue(struct rtnet_device *rtdev)
51{
52 set_bit(__RTNET_LINK_STATE_XOFF, &rtdev->link_state);
53}
54
55static inline int rtnetif_queue_stopped(struct rtnet_device *rtdev)
56{
57 return test_bit(__RTNET_LINK_STATE_XOFF, &rtdev->link_state);
58}
59
60static inline int rtnetif_running(struct rtnet_device *rtdev)
61{
62 return test_bit(__RTNET_LINK_STATE_START, &rtdev->link_state);
63}
64
65static inline int rtnetif_device_present(struct rtnet_device *rtdev)
66{
67 return test_bit(__RTNET_LINK_STATE_PRESENT, &rtdev->link_state);
68}
69
70static inline void rtnetif_device_detach(struct rtnet_device *rtdev)
71{
72 if (test_and_clear_bit(__RTNET_LINK_STATE_PRESENT,
73 &rtdev->link_state) &&
74 rtnetif_running(rtdev)) {
75 rtnetif_stop_queue(rtdev);
76 }
77}
78
79static inline void rtnetif_device_attach(struct rtnet_device *rtdev)
80{
81 if (!test_and_set_bit(__RTNET_LINK_STATE_PRESENT, &rtdev->link_state) &&
82 rtnetif_running(rtdev)) {
83 rtnetif_wake_queue(rtdev);
84 /* __netdev_watchdog_up(rtdev); */
85 }
86}
87
88static inline void rtnetif_carrier_on(struct rtnet_device *rtdev)
89{
90 clear_bit(__RTNET_LINK_STATE_NOCARRIER, &rtdev->link_state);
91 /*
92 if (netif_running(dev))
93 __netdev_watchdog_up(dev);
94 */
95}
96
97static inline void rtnetif_carrier_off(struct rtnet_device *rtdev)
98{
99 set_bit(__RTNET_LINK_STATE_NOCARRIER, &rtdev->link_state);
100}
101
102static inline int rtnetif_carrier_ok(struct rtnet_device *rtdev)
103{
104 return !test_bit(__RTNET_LINK_STATE_NOCARRIER, &rtdev->link_state);
105}
106
107#define NIPQUAD(addr) \
108 ((unsigned char *)&addr)[0], ((unsigned char *)&addr)[1], \
109 ((unsigned char *)&addr)[2], ((unsigned char *)&addr)[3]
110#define NIPQUAD_FMT "%u.%u.%u.%u"
111
112#endif /* __KERNEL__ */
113
114#endif /* __RTNET_PORT_H_ */
Real-Time Driver Model for Xenomai, driver API header.