Xenomai  3.1
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  * network layer protocol (layer 3)
37  */
38 
39 #define RTPACKET_HASH_TBL_SIZE 64
40 #define RTPACKET_HASH_KEY_MASK (RTPACKET_HASH_TBL_SIZE - 1)
41 
42 struct rtpacket_type {
43  struct list_head list_entry;
44 
45  unsigned short type;
46  short refcount;
47 
48  int (*handler)(struct rtskb *, struct rtpacket_type *);
49  int (*err_handler)(struct rtskb *, struct rtnet_device *,
50  struct rtpacket_type *);
51  bool (*trylock)(struct rtpacket_type *);
52  void (*unlock)(struct rtpacket_type *);
53 
54  struct module *owner;
55 };
56 
57 int __rtdev_add_pack(struct rtpacket_type *pt, struct module *module);
58 #define rtdev_add_pack(pt) __rtdev_add_pack(pt, THIS_MODULE)
59 
60 void rtdev_remove_pack(struct rtpacket_type *pt);
61 
62 static inline bool rtdev_lock_pack(struct rtpacket_type *pt)
63 {
64  return try_module_get(pt->owner);
65 }
66 
67 static inline void rtdev_unlock_pack(struct rtpacket_type *pt)
68 {
69  module_put(pt->owner);
70 }
71 
72 void rt_stack_connect(struct rtnet_device *rtdev, struct rtnet_mgr *mgr);
73 void rt_stack_disconnect(struct rtnet_device *rtdev);
74 
75 #if IS_ENABLED(CONFIG_XENO_DRIVERS_NET_DRV_LOOPBACK)
76 void rt_stack_deliver(struct rtskb *rtskb);
77 #endif /* CONFIG_XENO_DRIVERS_NET_DRV_LOOPBACK */
78 
79 int rt_stack_mgr_init(struct rtnet_mgr *mgr);
80 void rt_stack_mgr_delete(struct rtnet_mgr *mgr);
81 
82 void rtnetif_rx(struct rtskb *skb);
83 
84 static inline void rtnetif_tx(struct rtnet_device *rtdev)
85 {
86 }
87 
88 static inline void rt_mark_stack_mgr(struct rtnet_device *rtdev)
89 {
90  rtdm_event_signal(rtdev->stack_event);
91 }
92 
93 #endif /* __KERNEL__ */
94 
95 #endif /* __STACK_MGR_H_ */
void rtdm_event_signal(rtdm_event_t *event)
Signal an event occurrence
Definition: drvlib.c:824