master/master.h
branchredundancy
changeset 2158 69f2b2702336
parent 2115 2ec1239216e5
child 2267 2d36f36a433c
--- a/master/master.h	Wed Nov 09 12:58:09 2011 +0100
+++ b/master/master.h	Wed Nov 09 14:53:33 2011 +0100
@@ -137,6 +137,39 @@
 
 /*****************************************************************************/
 
+/** Device statistics.
+ */
+typedef struct {
+    u64 tx_count; /**< Number of frames sent. */
+    u64 last_tx_count; /**< Number of frames sent of last statistics cycle. */
+    u64 rx_count; /**< Number of frames received. */
+    u64 last_rx_count; /**< Number of frames received of last statistics
+                         cycle. */
+    u64 tx_bytes; /**< Number of bytes sent. */
+    u64 last_tx_bytes; /**< Number of bytes sent of last statistics cycle. */
+    u64 rx_bytes; /**< Number of bytes received. */
+    u64 last_rx_bytes; /**< Number of bytes received of last statistics cycle.
+                        */
+    u64 last_loss; /**< Tx/Rx difference of last statistics cycle. */
+    unsigned int tx_frame_rates[EC_RATE_COUNT]; /**< Transmit rates in
+                                                  frames/s for different
+                                                  statistics cycle periods. */
+    unsigned int rx_frame_rates[EC_RATE_COUNT]; /**< Receive rates in
+                                                  frames/s for different
+                                                  statistics cycle periods. */
+    unsigned int tx_byte_rates[EC_RATE_COUNT]; /**< Transmit rates in byte/s
+                                                 for different statistics
+                                                 cycle periods. */
+    unsigned int rx_byte_rates[EC_RATE_COUNT]; /**< Receive rates in byte/s
+                                                 for different statistics
+                                                 cycle periods. */
+    int loss_rates[EC_RATE_COUNT]; /**< Frame loss rates for different
+                                     statistics cycle periods. */
+    unsigned long jiffies; /**< Jiffies of last statistic cycle. */
+} ec_device_stats_t;
+
+/*****************************************************************************/
+
 /** EtherCAT master.
  *
  * Manages slaves, domains and IO.
@@ -159,6 +192,7 @@
     ec_device_t backup_device; /**< EtherCAT backup device. */
     const uint8_t *backup_mac; /**< MAC address of backup device. */
     struct semaphore device_sem; /**< Device semaphore. */
+    ec_device_stats_t device_stats; /**< Device statistics. */
 
     ec_fsm_master_t fsm; /**< Master state machine. */
     ec_datagram_t fsm_datagram; /**< Datagram used for state machines. */
@@ -309,6 +343,8 @@
 void ec_master_internal_send_cb(void *);
 void ec_master_internal_receive_cb(void *);
 
-/*****************************************************************************/
-
-#endif
+extern const unsigned int rate_intervals[EC_RATE_COUNT]; // see master.c
+
+/*****************************************************************************/
+
+#endif