72 typedef struct |
72 typedef struct |
73 { |
73 { |
74 unsigned int timeouts; /**< datagram timeouts */ |
74 unsigned int timeouts; /**< datagram timeouts */ |
75 unsigned int delayed; /**< delayed datagrams */ |
75 unsigned int delayed; /**< delayed datagrams */ |
76 unsigned int corrupted; /**< corrupted frames */ |
76 unsigned int corrupted; /**< corrupted frames */ |
77 unsigned int unmatched; /**< unmatched datagrams */ |
77 unsigned int skipped; /**< skipped datagrams (the ones that were |
|
78 requeued when not yet received) */ |
|
79 unsigned int unmatched; /**< unmatched datagrams (received, but not |
|
80 queued any longer) */ |
78 cycles_t t_last; /**< time of last output */ |
81 cycles_t t_last; /**< time of last output */ |
79 } |
82 } |
80 ec_stats_t; |
83 ec_stats_t; |
81 |
84 |
82 /*****************************************************************************/ |
85 /*****************************************************************************/ |
92 unsigned int reserved; /**< non-zero, if the master is reserved for RT */ |
95 unsigned int reserved; /**< non-zero, if the master is reserved for RT */ |
93 unsigned int index; /**< master index */ |
96 unsigned int index; /**< master index */ |
94 |
97 |
95 struct kobject kobj; /**< kobject */ |
98 struct kobject kobj; /**< kobject */ |
96 |
99 |
|
100 ec_device_t *device; /**< EtherCAT device */ |
|
101 |
|
102 ec_fsm_t fsm; /**< master state machine */ |
|
103 ec_master_mode_t mode; /**< master mode */ |
|
104 |
97 struct list_head slaves; /**< list of slaves on the bus */ |
105 struct list_head slaves; /**< list of slaves on the bus */ |
98 unsigned int slave_count; /**< number of slaves on the bus */ |
106 unsigned int slave_count; /**< number of slaves on the bus */ |
99 |
|
100 ec_device_t *device; /**< EtherCAT device */ |
|
101 |
107 |
102 struct list_head datagram_queue; /**< datagram queue */ |
108 struct list_head datagram_queue; /**< datagram queue */ |
103 uint8_t datagram_index; /**< current datagram index */ |
109 uint8_t datagram_index; /**< current datagram index */ |
104 |
110 |
105 struct list_head domains; /**< list of domains */ |
111 struct list_head domains; /**< list of domains */ |
107 int debug_level; /**< master debug level */ |
113 int debug_level; /**< master debug level */ |
108 ec_stats_t stats; /**< cyclic statistics */ |
114 ec_stats_t stats; /**< cyclic statistics */ |
109 |
115 |
110 struct workqueue_struct *workqueue; /**< master workqueue */ |
116 struct workqueue_struct *workqueue; /**< master workqueue */ |
111 struct work_struct idle_work; /**< free run work object */ |
117 struct work_struct idle_work; /**< free run work object */ |
112 ec_fsm_t fsm; /**< master state machine */ |
118 uint32_t idle_cycle_times[HZ]; /**< Idle cycle times ring */ |
113 ec_master_mode_t mode; /**< master mode */ |
119 unsigned int idle_cycle_time_pos; /**< time ring buffer position */ |
114 |
120 |
115 struct timer_list eoe_timer; /**< EoE timer object */ |
121 struct timer_list eoe_timer; /**< EoE timer object */ |
|
122 uint32_t eoe_cycle_times[HZ]; /**< EoE cycle times ring */ |
|
123 unsigned int eoe_cycle_time_pos; /**< time ring buffer position */ |
116 unsigned int eoe_running; /**< non-zero, if EoE processing is active. */ |
124 unsigned int eoe_running; /**< non-zero, if EoE processing is active. */ |
|
125 unsigned int eoe_checked; /**< non-zero, if EoE processing is not |
|
126 necessary. */ |
117 struct list_head eoe_handlers; /**< Ethernet-over-EtherCAT handlers */ |
127 struct list_head eoe_handlers; /**< Ethernet-over-EtherCAT handlers */ |
|
128 |
118 spinlock_t internal_lock; /**< spinlock used in idle mode */ |
129 spinlock_t internal_lock; /**< spinlock used in idle mode */ |
119 int (*request_cb)(void *); /**< lock request callback */ |
130 int (*request_cb)(void *); /**< lock request callback */ |
120 void (*release_cb)(void *); /**< lock release callback */ |
131 void (*release_cb)(void *); /**< lock release callback */ |
121 void *cb_data; /**< data parameter of locking callbacks */ |
132 void *cb_data; /**< data parameter of locking callbacks */ |
122 |
133 |
137 // EoE |
148 // EoE |
138 void ec_master_eoe_start(ec_master_t *); |
149 void ec_master_eoe_start(ec_master_t *); |
139 void ec_master_eoe_stop(ec_master_t *); |
150 void ec_master_eoe_stop(ec_master_t *); |
140 |
151 |
141 // IO |
152 // IO |
142 void ec_master_receive(ec_master_t *, const uint8_t *, size_t); |
153 void ec_master_receive_datagrams(ec_master_t *, const uint8_t *, size_t); |
143 void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *); |
154 void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *); |
144 |
155 |
145 // slave management |
156 // slave management |
146 int ec_master_bus_scan(ec_master_t *); |
157 int ec_master_bus_scan(ec_master_t *); |
147 |
158 |
148 // misc. |
159 // misc. |
149 void ec_master_output_stats(ec_master_t *); |
160 void ec_master_output_stats(ec_master_t *); |
150 void ec_master_clear_slaves(ec_master_t *); |
161 void ec_master_clear_slaves(ec_master_t *); |
|
162 void ec_master_measure_bus_time(ec_master_t *); |
151 |
163 |
152 // other methods |
164 // other methods |
153 void ec_sync_config(const ec_sii_sync_t *, const ec_slave_t *, uint8_t *); |
165 void ec_sync_config(const ec_sii_sync_t *, const ec_slave_t *, uint8_t *); |
154 void ec_fmmu_config(const ec_fmmu_t *, const ec_slave_t *, uint8_t *); |
166 void ec_fmmu_config(const ec_fmmu_t *, const ec_slave_t *, uint8_t *); |
155 void ec_master_calc_addressing(ec_master_t *); |
167 void ec_master_calc_addressing(ec_master_t *); |