author | Florian Pose <fp@igh-essen.com> |
Wed, 10 May 2006 11:33:10 +0000 | |
changeset 225 | 9e8150db6fc8 |
parent 218 | 80fb87518f3d |
child 235 | f973808540a6 |
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 |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
11 |
* as published by the Free Software Foundation; version 2 of the License. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
12 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
13 |
* 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
|
14 |
* 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
|
15 |
* 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
|
16 |
* GNU General Public License for more details. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
17 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
18 |
* 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
|
19 |
* 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
|
20 |
* 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
|
21 |
* |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
24 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
25 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
26 |
Ethernet-over-EtherCAT (EoE) |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
27 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
28 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
29 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
30 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
#include <linux/list.h> |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
32 |
#include <linux/netdevice.h> |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
#include "../include/ecrt.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
#include "globals.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
#include "slave.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include "command.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
41 |
/** |
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
42 |
Queued frame structure. |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
43 |
*/ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
44 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
45 |
typedef struct |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
46 |
{ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
47 |
struct list_head queue; /**< list item */ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
48 |
struct sk_buff *skb; /**< socket buffer */ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
49 |
} |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
50 |
ec_eoe_frame_t; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
51 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
52 |
/*****************************************************************************/ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
53 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
54 |
typedef struct ec_eoe ec_eoe_t; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
55 |
|
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
56 |
/** |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
57 |
Ethernet-over-EtherCAT (EoE) Object. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
58 |
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
|
59 |
EoE protocol. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
60 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
61 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
62 |
struct ec_eoe |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
{ |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
64 |
struct list_head list; /**< list item */ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
65 |
ec_slave_t *slave; /**< pointer to the corresponding slave */ |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
66 |
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
|
67 |
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
|
68 |
struct net_device_stats stats; /**< device statistics */ |
210
1cc6bcb1e6ae
EoE frame receiving; regarding open/stop commands.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
69 |
uint8_t opened; /**< net_device is opened */ |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
uint8_t rx_expected_fragment; /**< next expected fragment number */ |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
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
|
81 |
size_t tx_offset; /**< number of octets sent */ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
82 |
}; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
|
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
86 |
int ec_eoe_init(ec_eoe_t *, ec_slave_t *); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
void ec_eoe_clear(ec_eoe_t *); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
void ec_eoe_run(ec_eoe_t *); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
void ec_eoe_print(const ec_eoe_t *); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
/*****************************************************************************/ |