Xenomai  3.1
rtcfg_event.h
1 /***
2  *
3  * include/rtcfg/rtcfg_event.h
4  *
5  * Real-Time Configuration Distribution Protocol
6  *
7  * Copyright (C) 2003-2005 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 __RTCFG_EVENT_H_
26 #define __RTCFG_EVENT_H_
27 
28 #include <linux/if_ether.h>
29 #include <linux/netdevice.h>
30 
31 #include <rtcfg_chrdev.h>
32 #include <rtdev.h>
33 #include <rtnet_internal.h>
34 #include <rtnet_rtpc.h>
35 
36 #define FLAG_TIMER_STARTED 16
37 #define FLAG_TIMER_SHUTDOWN 17
38 #define FLAG_TIMER_PENDING 18
39 
40 #define _FLAG_TIMER_STARTED (1 << FLAG_TIMER_STARTED)
41 #define _FLAG_TIMER_SHUTDOWN (1 << FLAG_TIMER_SHUTDOWN)
42 #define _FLAG_TIMER_PENDING (1 << FLAG_TIMER_PENDING)
43 
44 typedef enum {
45  RTCFG_MAIN_OFF,
46  RTCFG_MAIN_SERVER_RUNNING,
47  RTCFG_MAIN_CLIENT_0,
48  RTCFG_MAIN_CLIENT_1,
49  RTCFG_MAIN_CLIENT_ANNOUNCED,
50  RTCFG_MAIN_CLIENT_ALL_KNOWN,
51  RTCFG_MAIN_CLIENT_ALL_FRAMES,
52  RTCFG_MAIN_CLIENT_2,
53  RTCFG_MAIN_CLIENT_READY
54 } RTCFG_MAIN_STATE;
55 
56 struct rtcfg_station {
57  u8 mac_addr[ETH_ALEN]; /* Ethernet-specific! */
58  u8 flags;
59 };
60 
61 struct rtcfg_device {
62  RTCFG_MAIN_STATE state;
63  u32 other_stations;
64  u32 stations_found;
65  u32 stations_ready;
66  rtdm_mutex_t dev_mutex;
67  struct list_head event_calls;
68  rtdm_lock_t event_calls_lock;
69  rtdm_timer_t timer;
70  unsigned long flags;
71  unsigned int burstrate;
72 #ifdef CONFIG_XENO_OPT_VFILE
73  struct xnvfile_directory proc_entry;
74  struct xnvfile_regular proc_state_vfile;
75  struct xnvfile_regular proc_stations_vfile;
76 #endif
77 
78  union {
79  struct {
80  unsigned int addr_type;
81  union {
82 #if IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4)
83  u32 ip_addr;
84 #endif
85  } srv_addr;
86  u8 srv_mac_addr[MAX_ADDR_LEN];
87  u8 *stage2_buffer;
88  u32 cfg_len;
89  u32 cfg_offs;
90  unsigned int packet_counter;
91  u32 chain_len;
92  struct rtskb *stage2_chain;
93  u32 max_stations;
94  struct rtcfg_station *station_addr_list;
95  } clt;
96 
97  struct {
98  u32 clients_configured;
99  struct list_head conn_list;
100  u16 heartbeat;
101  u64 heartbeat_timeout;
102  } srv;
103  } spec;
104 };
105 
106 extern struct rtcfg_device device[MAX_RT_DEVICES];
107 extern const char *rtcfg_event[];
108 extern const char *rtcfg_main_state[];
109 
110 int rtcfg_do_main_event(int ifindex, RTCFG_EVENT event_id, void *event_data);
111 void rtcfg_next_main_state(int ifindex, RTCFG_MAIN_STATE state);
112 
113 void rtcfg_queue_blocking_call(int ifindex, struct rt_proc_call *call);
114 struct rt_proc_call *rtcfg_dequeue_blocking_call(int ifindex);
115 void rtcfg_complete_cmd(int ifindex, RTCFG_EVENT event_id, int result);
116 void rtcfg_reset_device(int ifindex);
117 
118 void rtcfg_init_state_machines(void);
119 void rtcfg_cleanup_state_machines(void);
120 
121 #endif /* __RTCFG_EVENT_H_ */
ipipe_spinlock_t rtdm_lock_t
Lock variable.
Definition: driver.h:551