135 unsigned long output_jiffies; /**< time of last output */ |
135 unsigned long output_jiffies; /**< time of last output */ |
136 } ec_stats_t; |
136 } ec_stats_t; |
137 |
137 |
138 /*****************************************************************************/ |
138 /*****************************************************************************/ |
139 |
139 |
|
140 /** Device statistics. |
|
141 */ |
|
142 typedef struct { |
|
143 u64 tx_count; /**< Number of frames sent. */ |
|
144 u64 last_tx_count; /**< Number of frames sent of last statistics cycle. */ |
|
145 u64 rx_count; /**< Number of frames received. */ |
|
146 u64 last_rx_count; /**< Number of frames received of last statistics |
|
147 cycle. */ |
|
148 u64 tx_bytes; /**< Number of bytes sent. */ |
|
149 u64 last_tx_bytes; /**< Number of bytes sent of last statistics cycle. */ |
|
150 u64 rx_bytes; /**< Number of bytes received. */ |
|
151 u64 last_rx_bytes; /**< Number of bytes received of last statistics cycle. |
|
152 */ |
|
153 u64 last_loss; /**< Tx/Rx difference of last statistics cycle. */ |
|
154 s32 tx_frame_rates[EC_RATE_COUNT]; /**< Transmit rates in frames/s for |
|
155 different statistics cycle periods. |
|
156 */ |
|
157 s32 rx_frame_rates[EC_RATE_COUNT]; /**< Receive rates in frames/s for |
|
158 different statistics cycle periods. |
|
159 */ |
|
160 s32 tx_byte_rates[EC_RATE_COUNT]; /**< Transmit rates in byte/s for |
|
161 different statistics cycle periods. */ |
|
162 s32 rx_byte_rates[EC_RATE_COUNT]; /**< Receive rates in byte/s for |
|
163 different statistics cycle periods. */ |
|
164 s32 loss_rates[EC_RATE_COUNT]; /**< Frame loss rates for different |
|
165 statistics cycle periods. */ |
|
166 unsigned long jiffies; /**< Jiffies of last statistic cycle. */ |
|
167 } ec_device_stats_t; |
|
168 |
|
169 /*****************************************************************************/ |
|
170 |
140 /** EtherCAT master. |
171 /** EtherCAT master. |
141 * |
172 * |
142 * Manages slaves, domains and IO. |
173 * Manages slaves, domains and IO. |
143 */ |
174 */ |
144 struct ec_master { |
175 struct ec_master { |
152 struct class_device *class_device; /**< Master class device. */ |
183 struct class_device *class_device; /**< Master class device. */ |
153 #endif |
184 #endif |
154 |
185 |
155 struct semaphore master_sem; /**< Master semaphore. */ |
186 struct semaphore master_sem; /**< Master semaphore. */ |
156 |
187 |
157 ec_device_t main_device; /**< EtherCAT main device. */ |
188 ec_device_t devices[EC_NUM_DEVICES]; /**< EtherCAT devices. */ |
158 const uint8_t *main_mac; /**< MAC address of main device. */ |
189 const uint8_t *macs[EC_NUM_DEVICES]; /**< Device MAC addresses. */ |
159 ec_device_t backup_device; /**< EtherCAT backup device. */ |
|
160 const uint8_t *backup_mac; /**< MAC address of backup device. */ |
|
161 struct semaphore device_sem; /**< Device semaphore. */ |
190 struct semaphore device_sem; /**< Device semaphore. */ |
|
191 ec_device_stats_t device_stats; /**< Device statistics. */ |
162 |
192 |
163 ec_fsm_master_t fsm; /**< Master state machine. */ |
193 ec_fsm_master_t fsm; /**< Master state machine. */ |
164 ec_datagram_t fsm_datagram; /**< Datagram used for state machines. */ |
194 ec_datagram_t fsm_datagram; /**< Datagram used for state machines. */ |
165 ec_master_phase_t phase; /**< Master phase. */ |
195 ec_master_phase_t phase; /**< Master phase. */ |
166 unsigned int active; /**< Master has been activated. */ |
196 unsigned int active; /**< Master has been activated. */ |
208 datagrams. */ |
238 datagrams. */ |
209 struct semaphore ext_queue_sem; /**< Semaphore protecting the \a |
239 struct semaphore ext_queue_sem; /**< Semaphore protecting the \a |
210 ext_datagram_queue. */ |
240 ext_datagram_queue. */ |
211 |
241 |
212 struct list_head external_datagram_queue; /**< External Datagram queue. */ |
242 struct list_head external_datagram_queue; /**< External Datagram queue. */ |
213 unsigned int send_interval; /**< Interval between calls to |
243 unsigned int send_interval; /**< Interval between two calls to |
214 ecrt_master_send */ |
244 ecrt_master_send(). */ |
215 size_t max_queue_size; /**< Maximum size of datagram queue */ |
245 size_t max_queue_size; /**< Maximum size of datagram queue */ |
216 |
246 |
217 unsigned int debug_level; /**< Master debug level. */ |
247 unsigned int debug_level; /**< Master debug level. */ |
218 ec_stats_t stats; /**< Cyclic statistics. */ |
248 ec_stats_t stats; /**< Cyclic statistics. */ |
219 |
249 |
308 void ec_master_request_op(ec_master_t *); |
338 void ec_master_request_op(ec_master_t *); |
309 |
339 |
310 void ec_master_internal_send_cb(void *); |
340 void ec_master_internal_send_cb(void *); |
311 void ec_master_internal_receive_cb(void *); |
341 void ec_master_internal_receive_cb(void *); |
312 |
342 |
313 /*****************************************************************************/ |
343 extern const unsigned int rate_intervals[EC_RATE_COUNT]; // see master.c |
314 |
344 |
315 #endif |
345 /*****************************************************************************/ |
|
346 |
|
347 #endif |