Xenomai  3.0-rc7
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 
56 
57 int rtdev_add_pack(struct rtpacket_type *pt);
58 int rtdev_remove_pack(struct rtpacket_type *pt);
59 
60 static inline bool rtdev_lock_pack(struct rtpacket_type *pt)
61 {
62  ++pt->refcount;
63  return true;
64 }
65 
66 static inline void rtdev_unlock_pack(struct rtpacket_type *pt)
67 {
68  --pt->refcount;
69 }
70 
71 void rt_stack_connect(struct rtnet_device *rtdev, struct rtnet_mgr *mgr);
72 void rt_stack_disconnect(struct rtnet_device *rtdev);
73 
74 #if IS_ENABLED(CONFIG_XENO_DRIVERS_NET_DRV_LOOPBACK)
75 void rt_stack_deliver(struct rtskb *rtskb);
76 #endif /* CONFIG_XENO_DRIVERS_NET_DRV_LOOPBACK */
77 
78 int rt_stack_mgr_init(struct rtnet_mgr *mgr);
79 void rt_stack_mgr_delete(struct rtnet_mgr *mgr);
80 
81 void rtnetif_rx(struct rtskb *skb);
82 
83 static inline void rtnetif_tx(struct rtnet_device *rtdev)
84 {
85 }
86 
87 static inline void rt_mark_stack_mgr(struct rtnet_device *rtdev)
88 {
89  rtdm_event_signal(rtdev->stack_event);
90 }
91 
92 #endif /* __KERNEL__ */
93 
94 #endif /* __STACK_MGR_H_ */
void rtdm_event_signal(rtdm_event_t *event)
Signal an event occurrence.
Definition: drvlib.c:688