Xenomai  3.0.8
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 
38 static inline void rtnetif_start_queue(struct rtnet_device *rtdev)
39 {
40  clear_bit(__RTNET_LINK_STATE_XOFF, &rtdev->link_state);
41 }
42 
43 static 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 static inline void rtnetif_stop_queue(struct rtnet_device *rtdev)
50 {
51  set_bit(__RTNET_LINK_STATE_XOFF, &rtdev->link_state);
52 }
53 
54 static inline int rtnetif_queue_stopped(struct rtnet_device *rtdev)
55 {
56  return test_bit(__RTNET_LINK_STATE_XOFF, &rtdev->link_state);
57 }
58 
59 static inline int rtnetif_running(struct rtnet_device *rtdev)
60 {
61  return test_bit(__RTNET_LINK_STATE_START, &rtdev->link_state);
62 }
63 
64 static inline int rtnetif_device_present(struct rtnet_device *rtdev)
65 {
66  return test_bit(__RTNET_LINK_STATE_PRESENT, &rtdev->link_state);
67 }
68 
69 static inline void rtnetif_device_detach(struct rtnet_device *rtdev)
70 {
71  if (test_and_clear_bit(__RTNET_LINK_STATE_PRESENT,
72  &rtdev->link_state) &&
73  rtnetif_running(rtdev)) {
74  rtnetif_stop_queue(rtdev);
75  }
76 }
77 
78 static inline void rtnetif_device_attach(struct rtnet_device *rtdev)
79 {
80  if (!test_and_set_bit(__RTNET_LINK_STATE_PRESENT,
81  &rtdev->link_state) &&
82  rtnetif_running(rtdev)) {
83  rtnetif_wake_queue(rtdev);
84  /* __netdev_watchdog_up(rtdev); */
85  }
86 }
87 
88 static 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 
97 static inline void rtnetif_carrier_off(struct rtnet_device *rtdev)
98 {
99  set_bit(__RTNET_LINK_STATE_NOCARRIER, &rtdev->link_state);
100 }
101 
102 static 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], \
109  ((unsigned char *)&addr)[1], \
110  ((unsigned char *)&addr)[2], \
111  ((unsigned char *)&addr)[3]
112 #define NIPQUAD_FMT "%u.%u.%u.%u"
113 
114 #endif /* __KERNEL__ */
115 
116 #endif /* __RTNET_PORT_H_ */
Real-Time Driver Model for Xenomai, driver API header.