37 #include "command.h" |
37 #include "command.h" |
38 |
38 |
39 /*****************************************************************************/ |
39 /*****************************************************************************/ |
40 |
40 |
41 /** |
41 /** |
42 State of an EoE object. |
|
43 */ |
|
44 |
|
45 typedef enum |
|
46 { |
|
47 EC_EOE_RX_START, /**< start receiving and check for data. */ |
|
48 EC_EOE_RX_CHECK, /**< checking frame was sent. */ |
|
49 EC_EOE_RX_FETCH, /**< there is new data; fetching frame was sent. */ |
|
50 EC_EOE_TX_START, /**< start sending a queued frame. */ |
|
51 EC_EOE_TX_SENT /**< queued frame was sent. */ |
|
52 } |
|
53 ec_eoe_state_t; |
|
54 |
|
55 /*****************************************************************************/ |
|
56 |
|
57 /** |
|
58 Queued frame structure. |
42 Queued frame structure. |
59 */ |
43 */ |
60 |
44 |
61 typedef struct |
45 typedef struct |
62 { |
46 { |
65 } |
49 } |
66 ec_eoe_frame_t; |
50 ec_eoe_frame_t; |
67 |
51 |
68 /*****************************************************************************/ |
52 /*****************************************************************************/ |
69 |
53 |
|
54 typedef struct ec_eoe ec_eoe_t; |
|
55 |
70 /** |
56 /** |
71 Ethernet-over-EtherCAT (EoE) Object. |
57 Ethernet-over-EtherCAT (EoE) Object. |
72 The master creates one of these objects for each slave that supports the |
58 The master creates one of these objects for each slave that supports the |
73 EoE protocol. |
59 EoE protocol. |
74 */ |
60 */ |
75 |
61 |
76 typedef struct |
62 struct ec_eoe |
77 { |
63 { |
78 struct list_head list; /**< list item */ |
64 struct list_head list; /**< list item */ |
79 ec_slave_t *slave; /**< pointer to the corresponding slave */ |
65 ec_slave_t *slave; /**< pointer to the corresponding slave */ |
80 ec_eoe_state_t state; /**< state of the state machine */ |
66 void (*state)(ec_eoe_t *); /**< state function for the state machine */ |
81 struct net_device *dev; /**< net_device for virtual ethernet device */ |
67 struct net_device *dev; /**< net_device for virtual ethernet device */ |
|
68 struct net_device_stats stats; /**< device statistics */ |
82 uint8_t opened; /**< net_device is opened */ |
69 uint8_t opened; /**< net_device is opened */ |
83 struct sk_buff *skb; /**< current rx socket buffer */ |
70 struct sk_buff *rx_skb; /**< current rx socket buffer */ |
84 off_t skb_offset; /**< current write pointer in the socket buffer */ |
71 off_t rx_skb_offset; /**< current write pointer in the socket buffer */ |
85 size_t skb_size; /**< size of the allocated socket buffer memory */ |
72 size_t rx_skb_size; /**< size of the allocated socket buffer memory */ |
86 uint8_t expected_fragment; /**< expected fragment */ |
73 uint8_t rx_expected_fragment; /**< next expected fragment number */ |
87 struct net_device_stats stats; /**< device statistics */ |
|
88 struct list_head tx_queue; /**< queue for frames to send */ |
74 struct list_head tx_queue; /**< queue for frames to send */ |
89 unsigned int tx_queue_active; /**< kernel netif queue started */ |
75 unsigned int tx_queue_active; /**< kernel netif queue started */ |
90 unsigned int queued_frames; /**< number of frames in the queue */ |
76 unsigned int tx_queued_frames; /**< number of frames in the queue */ |
91 spinlock_t tx_queue_lock; /**< spinlock for the send queue */ |
77 spinlock_t tx_queue_lock; /**< spinlock for the send queue */ |
92 ec_eoe_frame_t *tx_frame; /**< current TX frame */ |
78 ec_eoe_frame_t *tx_frame; /**< current TX frame */ |
93 uint8_t tx_frame_number; /**< number of the transmitted frame */ |
79 uint8_t tx_frame_number; /**< number of the transmitted frame */ |
94 uint8_t tx_fragment_number; /**< number of the fragment */ |
80 uint8_t tx_fragment_number; /**< number of the fragment */ |
95 size_t tx_offset; /**< numbero of octets sent */ |
81 size_t tx_offset; /**< number of octets sent */ |
96 } |
82 }; |
97 ec_eoe_t; |
|
98 |
83 |
99 /*****************************************************************************/ |
84 /*****************************************************************************/ |
100 |
85 |
101 int ec_eoe_init(ec_eoe_t *, ec_slave_t *); |
86 int ec_eoe_init(ec_eoe_t *, ec_slave_t *); |
102 void ec_eoe_clear(ec_eoe_t *); |
87 void ec_eoe_clear(ec_eoe_t *); |