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