6 * |
6 * |
7 * This file is part of the IgH EtherCAT Master. |
7 * This file is part of the IgH EtherCAT Master. |
8 * |
8 * |
9 * The IgH EtherCAT Master is free software; you can redistribute it |
9 * The IgH EtherCAT Master is free software; you can redistribute it |
10 * and/or modify it under the terms of the GNU General Public License |
10 * and/or modify it under the terms of the GNU General Public License |
11 * as published by the Free Software Foundation; version 2 of the License. |
11 * as published by the Free Software Foundation; either version 2 of the |
|
12 * License, or (at your option) any later version. |
12 * |
13 * |
13 * The IgH EtherCAT Master is distributed in the hope that it will be |
14 * The IgH EtherCAT Master is distributed in the hope that it will be |
14 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 * GNU General Public License for more details. |
17 * GNU General Public License for more details. |
17 * |
18 * |
18 * You should have received a copy of the GNU General Public License |
19 * You should have received a copy of the GNU General Public License |
19 * along with the IgH EtherCAT Master; if not, write to the Free Software |
20 * along with the IgH EtherCAT Master; if not, write to the Free Software |
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
22 * |
|
23 * The right to use EtherCAT Technology is granted and comes free of |
|
24 * charge under condition of compatibility of product made by |
|
25 * Licensee. People intending to distribute/sell products based on the |
|
26 * code, have to sign an agreement to guarantee that products using |
|
27 * software based on IgH EtherCAT master stay compatible with the actual |
|
28 * EtherCAT specification (which are released themselves as an open |
|
29 * standard) as the (only) precondition to have the right to use EtherCAT |
|
30 * Technology, IP and trade marks. |
21 * |
31 * |
22 *****************************************************************************/ |
32 *****************************************************************************/ |
23 |
33 |
24 /** |
34 /** |
25 \file |
35 \file |
27 */ |
37 */ |
28 |
38 |
29 /*****************************************************************************/ |
39 /*****************************************************************************/ |
30 |
40 |
31 #include <linux/list.h> |
41 #include <linux/list.h> |
|
42 #include <linux/netdevice.h> |
32 |
43 |
33 #include "../include/ecrt.h" |
44 #include "../include/ecrt.h" |
34 #include "globals.h" |
45 #include "globals.h" |
35 #include "slave.h" |
46 #include "slave.h" |
36 #include "command.h" |
47 #include "command.h" |
37 |
48 |
38 /*****************************************************************************/ |
49 /*****************************************************************************/ |
39 |
50 |
40 /** |
51 /** |
41 State of an EoE object. |
52 Queued frame structure. |
42 */ |
53 */ |
43 |
54 |
44 typedef enum |
55 typedef struct |
45 { |
56 { |
46 EC_EOE_IDLE, /**< Idle. The next step ist to check for data. */ |
57 struct list_head queue; /**< list item */ |
47 EC_EOE_CHECKING, /**< Checking frame was sent. */ |
58 struct sk_buff *skb; /**< socket buffer */ |
48 EC_EOE_FETCHING /**< There is new data. Fetching frame was sent. */ |
|
49 } |
59 } |
50 ec_eoe_state_t; |
60 ec_eoe_frame_t; |
51 |
61 |
52 /*****************************************************************************/ |
62 /*****************************************************************************/ |
53 |
63 |
|
64 typedef struct ec_eoe ec_eoe_t; |
|
65 |
54 /** |
66 /** |
55 Ethernet-over-EtherCAT (EoE) Object. |
67 Ethernet-over-EtherCAT (EoE) handler. |
56 The master creates one of these objects for each slave that supports the |
68 The master creates one of these objects for each slave that supports the |
57 EoE protocol. |
69 EoE protocol. |
58 */ |
70 */ |
59 |
71 |
60 typedef struct |
72 struct ec_eoe |
61 { |
73 { |
62 struct list_head list; /**< list item */ |
74 struct list_head list; /**< list item */ |
63 ec_slave_t *slave; /**< pointer to the corresponding slave */ |
75 ec_slave_t *slave; /**< pointer to the corresponding slave */ |
64 ec_eoe_state_t rx_state; /**< state of the state machine */ |
76 void (*state)(ec_eoe_t *); /**< state function for the state machine */ |
65 } |
77 struct net_device *dev; /**< net_device for virtual ethernet device */ |
66 ec_eoe_t; |
78 struct net_device_stats stats; /**< device statistics */ |
|
79 unsigned int opened; /**< net_device is opened */ |
|
80 struct sk_buff *rx_skb; /**< current rx socket buffer */ |
|
81 off_t rx_skb_offset; /**< current write pointer in the socket buffer */ |
|
82 size_t rx_skb_size; /**< size of the allocated socket buffer memory */ |
|
83 uint8_t rx_expected_fragment; /**< next expected fragment number */ |
|
84 struct list_head tx_queue; /**< queue for frames to send */ |
|
85 unsigned int tx_queue_active; /**< kernel netif queue started */ |
|
86 unsigned int tx_queued_frames; /**< number of frames in the queue */ |
|
87 spinlock_t tx_queue_lock; /**< spinlock for the send queue */ |
|
88 ec_eoe_frame_t *tx_frame; /**< current TX frame */ |
|
89 uint8_t tx_frame_number; /**< number of the transmitted frame */ |
|
90 uint8_t tx_fragment_number; /**< number of the fragment */ |
|
91 size_t tx_offset; /**< number of octets sent */ |
|
92 }; |
67 |
93 |
68 /*****************************************************************************/ |
94 /*****************************************************************************/ |
69 |
95 |
70 void ec_eoe_init(ec_eoe_t *, ec_slave_t *); |
96 int ec_eoe_init(ec_eoe_t *); |
71 void ec_eoe_clear(ec_eoe_t *); |
97 void ec_eoe_clear(ec_eoe_t *); |
72 void ec_eoe_run(ec_eoe_t *); |
98 void ec_eoe_run(ec_eoe_t *); |
|
99 unsigned int ec_eoe_active(const ec_eoe_t *); |
73 void ec_eoe_print(const ec_eoe_t *); |
100 void ec_eoe_print(const ec_eoe_t *); |
74 |
101 |
75 /*****************************************************************************/ |
102 /*****************************************************************************/ |