author | Florian Pose <fp@igh-essen.com> |
Tue, 07 Nov 2006 13:47:50 +0000 | |
branch | stable-1.1 |
changeset 1733 | 69f0fbc0dcab |
parent 1719 | 42ed27ae6785 |
child 1744 | 7bc131b92039 |
permissions | -rw-r--r-- |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
6 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
8 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
12 |
* License, or (at your option) any later version. |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
13 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
17 |
* GNU General Public License for more details. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
18 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
22 |
* |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
31 |
* |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
34 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
35 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
36 |
Ethernet-over-EtherCAT (EoE) |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
37 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
38 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
39 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
40 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <linux/list.h> |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
42 |
#include <linux/netdevice.h> |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
#include "../include/ecrt.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
#include "globals.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
#include "slave.h" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
47 |
#include "datagram.h" |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
|
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
51 |
/** |
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
52 |
Queued frame structure. |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
53 |
*/ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
54 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
55 |
typedef struct |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
56 |
{ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
57 |
struct list_head queue; /**< list item */ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
58 |
struct sk_buff *skb; /**< socket buffer */ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
59 |
} |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
60 |
ec_eoe_frame_t; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
61 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
62 |
/*****************************************************************************/ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
63 |
|
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
64 |
typedef struct ec_eoe ec_eoe_t; /**< \see ec_eoe */ |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
65 |
|
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
66 |
/** |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
67 |
Ethernet-over-EtherCAT (EoE) handler. |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
68 |
The master creates one of these objects for each slave that supports the |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
69 |
EoE protocol. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
70 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
71 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
72 |
struct ec_eoe |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
{ |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
74 |
struct list_head list; /**< list item */ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
75 |
ec_slave_t *slave; /**< pointer to the corresponding slave */ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
76 |
ec_datagram_t datagram; /**< datagram */ |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
77 |
void (*state)(ec_eoe_t *); /**< state function for the state machine */ |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
78 |
struct net_device *dev; /**< net_device for virtual ethernet device */ |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
79 |
struct net_device_stats stats; /**< device statistics */ |
235
f973808540a6
No master locking, if no EoE devices are "up".
Florian Pose <fp@igh-essen.com>
parents:
218
diff
changeset
|
80 |
unsigned int opened; /**< net_device is opened */ |
1719
42ed27ae6785
MERGE trunk -r516:527 -> branches/stable-1.1 (jiffies, bugfixes, pdo defines)
Florian Pose <fp@igh-essen.com>
parents:
1716
diff
changeset
|
81 |
unsigned long rate_jiffies; /**< time of last rate output */ |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
82 |
struct sk_buff *rx_skb; /**< current rx socket buffer */ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
83 |
off_t rx_skb_offset; /**< current write pointer in the socket buffer */ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
84 |
size_t rx_skb_size; /**< size of the allocated socket buffer memory */ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
85 |
uint8_t rx_expected_fragment; /**< next expected fragment number */ |
1716
9440f4ff25c7
MERGE trunk -r494:513 -> branches/stable-1.1 (SDO configuration, bugfixes, EoE frame rates)
Florian Pose <fp@igh-essen.com>
parents:
1715
diff
changeset
|
86 |
uint32_t rx_counter; /**< octets received during last second */ |
9440f4ff25c7
MERGE trunk -r494:513 -> branches/stable-1.1 (SDO configuration, bugfixes, EoE frame rates)
Florian Pose <fp@igh-essen.com>
parents:
1715
diff
changeset
|
87 |
uint32_t rx_rate; /**< receive rate (bps) */ |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
88 |
struct list_head tx_queue; /**< queue for frames to send */ |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
212
diff
changeset
|
89 |
unsigned int tx_queue_active; /**< kernel netif queue started */ |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
90 |
unsigned int tx_queued_frames; /**< number of frames in the queue */ |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
91 |
spinlock_t tx_queue_lock; /**< spinlock for the send queue */ |
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
92 |
ec_eoe_frame_t *tx_frame; /**< current TX frame */ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
93 |
uint8_t tx_frame_number; /**< number of the transmitted frame */ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
94 |
uint8_t tx_fragment_number; /**< number of the fragment */ |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
95 |
size_t tx_offset; /**< number of octets sent */ |
1716
9440f4ff25c7
MERGE trunk -r494:513 -> branches/stable-1.1 (SDO configuration, bugfixes, EoE frame rates)
Florian Pose <fp@igh-essen.com>
parents:
1715
diff
changeset
|
96 |
uint32_t tx_counter; /**< octets transmitted during last second */ |
9440f4ff25c7
MERGE trunk -r494:513 -> branches/stable-1.1 (SDO configuration, bugfixes, EoE frame rates)
Florian Pose <fp@igh-essen.com>
parents:
1715
diff
changeset
|
97 |
uint32_t tx_rate; /**< transmit rate (bps) */ |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
98 |
}; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
102 |
int ec_eoe_init(ec_eoe_t *); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
void ec_eoe_clear(ec_eoe_t *); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
void ec_eoe_run(ec_eoe_t *); |
1716
9440f4ff25c7
MERGE trunk -r494:513 -> branches/stable-1.1 (SDO configuration, bugfixes, EoE frame rates)
Florian Pose <fp@igh-essen.com>
parents:
1715
diff
changeset
|
105 |
int ec_eoe_active(const ec_eoe_t *); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
/*****************************************************************************/ |