Xenomai  3.0.8
stack_mgr.h
1 /***
2  *
3  * stack_mgr.h
4  *
5  * RTnet - real-time networking subsystem
6  * Copyright (C) 2002 Ulrich Marx <marx@fet.uni-hannover.de>
7  * 2003-2006 Jan Kiszka <jan.kiszka@web.de>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  */
24 
25 #ifndef __STACK_MGR_H_
26 #define __STACK_MGR_H_
27 
28 #ifdef __KERNEL__
29 
30 #include <linux/list.h>
31 
32 #include <rtnet_internal.h>
33 #include <rtdev.h>
34 
35 
36 /***
37  * network layer protocol (layer 3)
38  */
39 
40 #define RTPACKET_HASH_TBL_SIZE 64
41 #define RTPACKET_HASH_KEY_MASK (RTPACKET_HASH_TBL_SIZE-1)
42 
43 struct rtpacket_type {
44  struct list_head list_entry;
45 
46  unsigned short type;
47  short refcount;
48 
49  int (*handler)(struct rtskb *, struct rtpacket_type *);
50  int (*err_handler)(struct rtskb *, struct rtnet_device *,
51  struct rtpacket_type *);
52  bool (*trylock)(struct rtpacket_type *);
53  void (*unlock)(struct rtpacket_type *);
54 
55  struct module *owner;
56 };
57 
58 
59 int __rtdev_add_pack(struct rtpacket_type *pt, struct module *module);
60 #define rtdev_add_pack(pt) \
61  __rtdev_add_pack(pt, THIS_MODULE)
62 
63 void rtdev_remove_pack(struct rtpacket_type *pt);
64 
65 static inline bool rtdev_lock_pack(struct rtpacket_type *pt)
66 {
67  return try_module_get(pt->owner);
68 }
69 
70 static inline void rtdev_unlock_pack(struct rtpacket_type *pt)
71 {
72  module_put(pt->owner);
73 }
74 
75 void rt_stack_connect(struct rtnet_device *rtdev, struct rtnet_mgr *mgr);
76 void rt_stack_disconnect(struct rtnet_device *rtdev);
77 
78 #if IS_ENABLED(CONFIG_XENO_DRIVERS_NET_DRV_LOOPBACK)
79 void rt_stack_deliver(struct rtskb *rtskb);
80 #endif /* CONFIG_XENO_DRIVERS_NET_DRV_LOOPBACK */
81 
82 int rt_stack_mgr_init(struct rtnet_mgr *mgr);
83 void rt_stack_mgr_delete(struct rtnet_mgr *mgr);
84 
85 void rtnetif_rx(struct rtskb *skb);
86 
87 static inline void rtnetif_tx(struct rtnet_device *rtdev)
88 {
89 }
90 
91 static inline void rt_mark_stack_mgr(struct rtnet_device *rtdev)
92 {
93  rtdm_event_signal(rtdev->stack_event);
94 }
95 
96 #endif /* __KERNEL__ */
97 
98 #endif /* __STACK_MGR_H_ */
void rtdm_event_signal(rtdm_event_t *event)
Signal an event occurrence.
Definition: drvlib.c:784