Xenomai 3.3.2
Loading...
Searching...
No Matches
tdma.h
1/***
2 *
3 * include/rtmac/tdma/tdma.h
4 *
5 * RTmac - real-time networking media access control subsystem
6 * Copyright (C) 2002 Marc Kleine-Budde <kleine-budde@gmx.de>,
7 * 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 __TDMA_H_
26#define __TDMA_H_
27
28#include <rtdm/driver.h>
29
30#include <rtnet_rtpc.h>
31#include <rtmac/rtmac_disc.h>
32
33#define RTMAC_TYPE_TDMA 0x0001
34
35#define TDMA_MAGIC 0x3A0D4D0A
36
37#define TDMA_FLAG_CALIBRATED 1
38#define TDMA_FLAG_RECEIVED_SYNC 2
39#define TDMA_FLAG_MASTER 3 /* also set for backup masters */
40#define TDMA_FLAG_BACKUP_MASTER 4
41#define TDMA_FLAG_ATTACHED 5
42#define TDMA_FLAG_BACKUP_ACTIVE 6
43
44#define DEFAULT_SLOT 0
45#define DEFAULT_NRT_SLOT 1
46
47/* job IDs */
48#define WAIT_ON_SYNC -1
49#define XMIT_SYNC -2
50#define BACKUP_SYNC -3
51#define XMIT_REQ_CAL -4
52#define XMIT_RPL_CAL -5
53
54struct tdma_priv;
55
56struct tdma_job {
57 struct list_head entry;
58 int id;
59 unsigned int ref_count;
60};
61
62#define SLOT_JOB(job) ((struct tdma_slot *)(job))
63
64struct tdma_slot {
65 struct tdma_job head;
66
67 u64 offset;
68 unsigned int period;
69 unsigned int phasing;
70 unsigned int mtu;
71 unsigned int size;
72 struct rtskb_prio_queue *queue;
73 struct rtskb_prio_queue local_queue;
74};
75
76#define REQUEST_CAL_JOB(job) ((struct tdma_request_cal *)(job))
77
78struct tdma_request_cal {
79 struct tdma_job head;
80
81 struct tdma_priv *tdma;
82 u64 offset;
83 unsigned int period;
84 unsigned int phasing;
85 unsigned int cal_rounds;
86 u64 *cal_results;
87 u64 *result_buffer;
88};
89
90#define REPLY_CAL_JOB(job) ((struct tdma_reply_cal *)(job))
91
92struct tdma_reply_cal {
93 struct tdma_job head;
94
95 u32 reply_cycle;
96 u64 reply_offset;
97 struct rtskb *reply_rtskb;
98};
99
100struct tdma_priv {
101 unsigned int magic;
102 struct rtnet_device *rtdev;
103 char device_name[32];
104 struct rtdm_driver api_driver;
105 struct rtdm_device api_device;
106
107#ifdef ALIGN_RTOS_TASK
108 __u8 __align[(ALIGN_RTOS_TASK -
109 ((sizeof(unsigned int) + sizeof(struct rtnet_device *) +
110 sizeof(struct rtdm_device)) &
111 (ALIGN_RTOS_TASK - 1))) &
112 (ALIGN_RTOS_TASK - 1)];
113#endif
114 rtdm_task_t worker_task;
115 rtdm_event_t worker_wakeup;
116 rtdm_event_t xmit_event;
117 rtdm_event_t sync_event;
118
119 unsigned long flags;
120 unsigned int cal_rounds;
121 u32 current_cycle;
122 u64 current_cycle_start;
123 u64 master_packet_delay_ns;
124 nanosecs_rel_t clock_offset;
125
126 struct tdma_job sync_job;
127 struct tdma_job *first_job;
128 struct tdma_job *current_job;
129 volatile unsigned int job_list_revision;
130
131 unsigned int max_slot_id;
132 struct tdma_slot **slot_table;
133
134 struct rt_proc_call *calibration_call;
135 unsigned char master_hw_addr[MAX_ADDR_LEN];
136
137 rtdm_lock_t lock;
138
139#ifdef CONFIG_XENO_DRIVERS_NET_TDMA_MASTER
140 struct rtskb_pool cal_rtskb_pool;
141 u64 cycle_period;
142 u64 backup_sync_inc;
143#endif
144
145#ifdef CONFIG_XENO_OPT_VFILE
146 struct list_head list_entry;
147#endif
148};
149
150extern struct rtmac_disc tdma_disc;
151
152#endif /* __TDMA_H_ */
Real-Time Driver Model for Xenomai, driver API header.
pipeline_spinlock_t rtdm_lock_t
Lock variable.
Definition driver.h:552
int64_t nanosecs_rel_t
RTDM type for representing relative intervals.
Definition rtdm.h:49
RTDM device.
Definition driver.h:340
RTDM driver.
Definition driver.h:251