master/master.h
branchredundancy
changeset 2158 69f2b2702336
parent 2115 2ec1239216e5
child 2267 2d36f36a433c
equal deleted inserted replaced
2157:8fa0571f9996 2158:69f2b2702336
   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     unsigned int tx_frame_rates[EC_RATE_COUNT]; /**< Transmit rates in
       
   155                                                   frames/s for different
       
   156                                                   statistics cycle periods. */
       
   157     unsigned int rx_frame_rates[EC_RATE_COUNT]; /**< Receive rates in
       
   158                                                   frames/s for different
       
   159                                                   statistics cycle periods. */
       
   160     unsigned int tx_byte_rates[EC_RATE_COUNT]; /**< Transmit rates in byte/s
       
   161                                                  for different statistics
       
   162                                                  cycle periods. */
       
   163     unsigned int rx_byte_rates[EC_RATE_COUNT]; /**< Receive rates in byte/s
       
   164                                                  for different statistics
       
   165                                                  cycle periods. */
       
   166     int loss_rates[EC_RATE_COUNT]; /**< Frame loss rates for different
       
   167                                      statistics cycle periods. */
       
   168     unsigned long jiffies; /**< Jiffies of last statistic cycle. */
       
   169 } ec_device_stats_t;
       
   170 
       
   171 /*****************************************************************************/
       
   172 
   140 /** EtherCAT master.
   173 /** EtherCAT master.
   141  *
   174  *
   142  * Manages slaves, domains and IO.
   175  * Manages slaves, domains and IO.
   143  */
   176  */
   144 struct ec_master {
   177 struct ec_master {
   157     ec_device_t main_device; /**< EtherCAT main device. */
   190     ec_device_t main_device; /**< EtherCAT main device. */
   158     const uint8_t *main_mac; /**< MAC address of main device. */
   191     const uint8_t *main_mac; /**< MAC address of main device. */
   159     ec_device_t backup_device; /**< EtherCAT backup device. */
   192     ec_device_t backup_device; /**< EtherCAT backup device. */
   160     const uint8_t *backup_mac; /**< MAC address of backup device. */
   193     const uint8_t *backup_mac; /**< MAC address of backup device. */
   161     struct semaphore device_sem; /**< Device semaphore. */
   194     struct semaphore device_sem; /**< Device semaphore. */
       
   195     ec_device_stats_t device_stats; /**< Device statistics. */
   162 
   196 
   163     ec_fsm_master_t fsm; /**< Master state machine. */
   197     ec_fsm_master_t fsm; /**< Master state machine. */
   164     ec_datagram_t fsm_datagram; /**< Datagram used for state machines. */
   198     ec_datagram_t fsm_datagram; /**< Datagram used for state machines. */
   165     ec_master_phase_t phase; /**< Master phase. */
   199     ec_master_phase_t phase; /**< Master phase. */
   166     unsigned int active; /**< Master has been activated. */
   200     unsigned int active; /**< Master has been activated. */
   307 void ec_master_request_op(ec_master_t *);
   341 void ec_master_request_op(ec_master_t *);
   308 
   342 
   309 void ec_master_internal_send_cb(void *);
   343 void ec_master_internal_send_cb(void *);
   310 void ec_master_internal_receive_cb(void *);
   344 void ec_master_internal_receive_cb(void *);
   311 
   345 
   312 /*****************************************************************************/
   346 extern const unsigned int rate_intervals[EC_RATE_COUNT]; // see master.c
   313 
   347 
   314 #endif
   348 /*****************************************************************************/
       
   349 
       
   350 #endif