master/master.h
changeset 792 3778920f61e4
parent 758 8fa6f825eb7d
child 814 a51f857b1b2d
equal deleted inserted replaced
791:3b81d074735c 792:3778920f61e4
    51 #include "domain.h"
    51 #include "domain.h"
    52 #include "fsm_master.h"
    52 #include "fsm_master.h"
    53 
    53 
    54 /*****************************************************************************/
    54 /*****************************************************************************/
    55 
    55 
    56 /**
    56 /** EtherCAT master mode.
    57    EtherCAT master mode.
    57  */
    58 */
    58 typedef enum {
    59 
       
    60 typedef enum
       
    61 {
       
    62     EC_MASTER_MODE_ORPHANED,
    59     EC_MASTER_MODE_ORPHANED,
    63     EC_MASTER_MODE_IDLE,
    60     EC_MASTER_MODE_IDLE,
    64     EC_MASTER_MODE_OPERATION
    61     EC_MASTER_MODE_OPERATION
    65 }
    62 }
    66 ec_master_mode_t;
    63 ec_master_mode_t;
    67 
    64 
    68 /*****************************************************************************/
    65 /*****************************************************************************/
    69 
    66 
    70 /**
    67 /** Cyclic statistics.
    71    Cyclic statistics.
    68  */
    72 */
    69 typedef struct {
    73 
       
    74 typedef struct
       
    75 {
       
    76     unsigned int timeouts; /**< datagram timeouts */
    70     unsigned int timeouts; /**< datagram timeouts */
    77     unsigned int corrupted; /**< corrupted frames */
    71     unsigned int corrupted; /**< corrupted frames */
    78     unsigned int unmatched; /**< unmatched datagrams (received, but not
    72     unsigned int unmatched; /**< unmatched datagrams (received, but not
    79                                queued any longer) */
    73                                queued any longer) */
    80     unsigned long output_jiffies; /**< time of last output */
    74     unsigned long output_jiffies; /**< time of last output */
    81 }
    75 }
    82 ec_stats_t;
    76 ec_stats_t;
    83 
    77 
    84 /*****************************************************************************/
    78 /*****************************************************************************/
    85 
    79 
    86 /**
    80 /** EtherCAT master.
    87    EtherCAT master.
    81  *
    88    Manages slaves, domains and IO.
    82  * Manages slaves, domains and IO.
    89 */
    83  */
    90 
       
    91 struct ec_master
    84 struct ec_master
    92 {
    85 {
    93     struct kobject kobj; /**< kobject */
    86     struct kobject kobj; /**< kobject */
    94     unsigned int index; /**< master index */
    87     unsigned int index; /**< master index */
    95     unsigned int reserved; /**< non-zero, if the master is reserved for RT */
    88     unsigned int reserved; /**< non-zero, if the master is reserved for RT */
   108     unsigned int injection_seq_rt; /**< datagram injection sequence number
   101     unsigned int injection_seq_rt; /**< datagram injection sequence number
   109                                      for the realtime side */
   102                                      for the realtime side */
   110 
   103 
   111     struct list_head slaves; /**< list of slaves on the bus */
   104     struct list_head slaves; /**< list of slaves on the bus */
   112     unsigned int slave_count; /**< number of slaves on the bus */
   105     unsigned int slave_count; /**< number of slaves on the bus */
       
   106 
       
   107     struct list_head configs; /**< Bus configuration list. */
       
   108     unsigned int configs_attached; /**< Slave configurations were attached. */
   113     
   109     
   114     ec_request_state_t scan_state; /**< current scanning state */
   110     ec_request_state_t scan_state; /**< current scanning state */
   115     unsigned int allow_scan; /**< non-zero, if slave scanning is allowed */
   111     unsigned int allow_scan; /**< non-zero, if slave scanning is allowed */
   116     struct semaphore scan_sem; /**< semaphore protecting the scan_state
   112     struct semaphore scan_sem; /**< semaphore protecting the scan_state
   117                                  variable and the allow_scan flag */
   113                                  variable and the allow_scan flag */
   194 // datagram IO
   190 // datagram IO
   195 void ec_master_receive_datagrams(ec_master_t *, const uint8_t *, size_t);
   191 void ec_master_receive_datagrams(ec_master_t *, const uint8_t *, size_t);
   196 void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *);
   192 void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *);
   197 
   193 
   198 // misc.
   194 // misc.
       
   195 int ec_master_attach_slave_configs(ec_master_t *);
   199 void ec_master_output_stats(ec_master_t *);
   196 void ec_master_output_stats(ec_master_t *);
   200 #ifdef EC_EOE
   197 #ifdef EC_EOE
   201 void ec_master_clear_eoe_handlers(ec_master_t *);
   198 void ec_master_clear_eoe_handlers(ec_master_t *);
   202 #endif
   199 #endif
   203 void ec_master_destroy_slaves(ec_master_t *);
   200 void ec_master_destroy_slaves(ec_master_t *);