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
/***
 *
 *  stack_mgr.h
 *
 *  RTnet - real-time networking subsystem
 *  Copyright (C) 2002      Ulrich Marx <marx@fet.uni-hannover.de>
 *                2003-2006 Jan Kiszka <jan.kiszka@web.de>
 *
 *  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 __STACK_MGR_H_
#define __STACK_MGR_H_
 
#ifdef __KERNEL__
 
#include <linux/list.h>
 
#include <rtnet_internal.h>
#include <rtdev.h>
 
/***
 * network layer protocol (layer 3)
 */
 
#define RTPACKET_HASH_TBL_SIZE 64
#define RTPACKET_HASH_KEY_MASK (RTPACKET_HASH_TBL_SIZE - 1)
 
struct rtpacket_type {
   struct list_head list_entry;
 
   unsigned short type;
   short refcount;
 
   int (*handler)(struct rtskb *, struct rtpacket_type *);
   int (*err_handler)(struct rtskb *, struct rtnet_device *,
              struct rtpacket_type *);
   bool (*trylock)(struct rtpacket_type *);
   void (*unlock)(struct rtpacket_type *);
 
   struct module *owner;
};
 
int __rtdev_add_pack(struct rtpacket_type *pt, struct module *module);
#define rtdev_add_pack(pt) __rtdev_add_pack(pt, THIS_MODULE)
 
void rtdev_remove_pack(struct rtpacket_type *pt);
 
static inline bool rtdev_lock_pack(struct rtpacket_type *pt)
{
   return try_module_get(pt->owner);
}
 
static inline void rtdev_unlock_pack(struct rtpacket_type *pt)
{
   module_put(pt->owner);
}
 
void rt_stack_connect(struct rtnet_device *rtdev, struct rtnet_mgr *mgr);
void rt_stack_disconnect(struct rtnet_device *rtdev);
 
#if IS_ENABLED(CONFIG_XENO_DRIVERS_NET_DRV_LOOPBACK)
void rt_stack_deliver(struct rtskb *rtskb);
#endif /* CONFIG_XENO_DRIVERS_NET_DRV_LOOPBACK */
 
int rt_stack_mgr_init(struct rtnet_mgr *mgr);
void rt_stack_mgr_delete(struct rtnet_mgr *mgr);
 
void rtnetif_rx(struct rtskb *skb);
 
static inline void rtnetif_tx(struct rtnet_device *rtdev)
{
}
 
static inline void rt_mark_stack_mgr(struct rtnet_device *rtdev)
{
   rtdm_event_signal(rtdev->stack_event);
}
 
#endif /* __KERNEL__ */
 
#endif /* __STACK_MGR_H_ */