author | Florian Pose <fp@igh-essen.com> |
Thu, 13 Jul 2006 13:10:57 +0000 | |
branch | stable-1.1 |
changeset 1714 | f149465f4c63 |
parent 294 | feea8d850c65 |
child 314 | 26023e414f5c |
child 1715 | e675450f2174 |
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 |
|
294
feea8d850c65
Applied include patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
41 |
#include <linux/netdevice.h> |
210
1cc6bcb1e6ae
EoE frame receiving; regarding open/stop commands.
Florian Pose <fp@igh-essen.com>
parents:
208
diff
changeset
|
42 |
#include <linux/etherdevice.h> |
1cc6bcb1e6ae
EoE frame receiving; regarding open/stop commands.
Florian Pose <fp@igh-essen.com>
parents:
208
diff
changeset
|
43 |
|
145
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 "master.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
#include "slave.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
#include "mailbox.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
#include "ethernet.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
|
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
51 |
/** |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
52 |
Defines the debug level of EoE processing |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
53 |
|
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
54 |
0 = No debug messages. |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
55 |
1 = Output actions. |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
56 |
2 = Output actions and frame data. |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
57 |
*/ |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
58 |
|
216
e7f3e485c5b8
EoE: Corrected faulty MAC address.
Florian Pose <fp@igh-essen.com>
parents:
215
diff
changeset
|
59 |
#define EOE_DEBUG_LEVEL 0 |
215
b021aa6eee38
EoE: TCP traffic possible; TX fragmenting to do.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
60 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
|
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
63 |
void ec_eoe_flush(ec_eoe_t *); |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
64 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
65 |
// state functions |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
66 |
void ec_eoe_state_rx_start(ec_eoe_t *); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
67 |
void ec_eoe_state_rx_check(ec_eoe_t *); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
68 |
void ec_eoe_state_rx_fetch(ec_eoe_t *); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
69 |
void ec_eoe_state_tx_start(ec_eoe_t *); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
70 |
void ec_eoe_state_tx_sent(ec_eoe_t *); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
71 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
72 |
// net_device functions |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
73 |
int ec_eoedev_open(struct net_device *); |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
74 |
int ec_eoedev_stop(struct net_device *); |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
75 |
int ec_eoedev_tx(struct sk_buff *, struct net_device *); |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
76 |
struct net_device_stats *ec_eoedev_stats(struct net_device *); |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
77 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
78 |
/*****************************************************************************/ |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
79 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
80 |
/** |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
81 |
EoE constructor. |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
82 |
Initializes the EoE handler, creates a net_device and registeres it. |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
83 |
*/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
84 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
85 |
int ec_eoe_init(ec_eoe_t *eoe /**< EoE handler */) |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
86 |
{ |
213
8d723b9833a9
removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents:
212
diff
changeset
|
87 |
ec_eoe_t **priv; |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
88 |
int result, i; |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
89 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
90 |
eoe->slave = NULL; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
91 |
ec_datagram_init(&eoe->datagram); |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
92 |
eoe->state = ec_eoe_state_rx_start; |
210
1cc6bcb1e6ae
EoE frame receiving; regarding open/stop commands.
Florian Pose <fp@igh-essen.com>
parents:
208
diff
changeset
|
93 |
eoe->opened = 0; |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
94 |
eoe->rx_skb = NULL; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
95 |
eoe->rx_expected_fragment = 0; |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
96 |
INIT_LIST_HEAD(&eoe->tx_queue); |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
97 |
eoe->tx_frame = NULL; |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
98 |
eoe->tx_queue_active = 0; |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
99 |
eoe->tx_queued_frames = 0; |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
100 |
eoe->tx_queue_lock = SPIN_LOCK_UNLOCKED; |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
101 |
eoe->tx_frame_number = 0xFF; |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
102 |
memset(&eoe->stats, 0, sizeof(struct net_device_stats)); |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
103 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
104 |
if (!(eoe->dev = |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
105 |
alloc_netdev(sizeof(ec_eoe_t *), "eoe%d", ether_setup))) { |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
106 |
EC_ERR("Unable to allocate net_device for EoE handler!\n"); |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
107 |
goto out_return; |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
108 |
} |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
109 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
110 |
// initialize net_device |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
111 |
eoe->dev->open = ec_eoedev_open; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
112 |
eoe->dev->stop = ec_eoedev_stop; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
113 |
eoe->dev->hard_start_xmit = ec_eoedev_tx; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
114 |
eoe->dev->get_stats = ec_eoedev_stats; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
115 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
116 |
for (i = 0; i < ETH_ALEN; i++) |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
117 |
eoe->dev->dev_addr[i] = i | (i << 4); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
118 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
119 |
// initialize private data |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
120 |
priv = netdev_priv(eoe->dev); |
213
8d723b9833a9
removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents:
212
diff
changeset
|
121 |
*priv = eoe; |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
122 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
123 |
// Usually setting the MTU appropriately makes the upper layers |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
124 |
// do the frame fragmenting. In some cases this doesn't work |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
125 |
// so the MTU is left on the Ethernet standard value and fragmenting |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
126 |
// is done "manually". |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
127 |
#if 0 |
215
b021aa6eee38
EoE: TCP traffic possible; TX fragmenting to do.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
128 |
eoe->dev->mtu = slave->sii_rx_mailbox_size - ETH_HLEN - 10; |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
129 |
#endif |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
130 |
|
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
131 |
// connect the net_device to the kernel |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
132 |
if ((result = register_netdev(eoe->dev))) { |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
133 |
EC_ERR("Unable to register net_device: error %i\n", result); |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
134 |
goto out_free; |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
135 |
} |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
136 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
137 |
// make the last address octet unique |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
138 |
eoe->dev->dev_addr[ETH_ALEN - 1] = (uint8_t) eoe->dev->ifindex; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
139 |
|
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
140 |
return 0; |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
141 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
142 |
out_free: |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
143 |
free_netdev(eoe->dev); |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
144 |
eoe->dev = NULL; |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
145 |
out_return: |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
146 |
return -1; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
|
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
151 |
/** |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
152 |
EoE destructor. |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
153 |
Unregisteres the net_device and frees allocated memory. |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
154 |
*/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
155 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
156 |
void ec_eoe_clear(ec_eoe_t *eoe /**< EoE handler */) |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
{ |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
158 |
if (eoe->dev) { |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
159 |
unregister_netdev(eoe->dev); |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
160 |
free_netdev(eoe->dev); |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
161 |
} |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
162 |
|
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
163 |
// empty transmit queue |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
164 |
ec_eoe_flush(eoe); |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
165 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
166 |
if (eoe->tx_frame) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
167 |
dev_kfree_skb(eoe->tx_frame->skb); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
168 |
kfree(eoe->tx_frame); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
169 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
170 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
171 |
if (eoe->rx_skb) dev_kfree_skb(eoe->rx_skb); |
279
12f48c1cb143
Removed mbox_command out of slave.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
172 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
173 |
ec_datagram_clear(&eoe->datagram); |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
174 |
} |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
175 |
|
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
176 |
/*****************************************************************************/ |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
177 |
|
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
178 |
/** |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
179 |
Empties the transmit queue. |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
180 |
*/ |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
181 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
182 |
void ec_eoe_flush(ec_eoe_t *eoe /**< EoE handler */) |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
183 |
{ |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
184 |
ec_eoe_frame_t *frame, *next; |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
185 |
|
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
186 |
spin_lock_bh(&eoe->tx_queue_lock); |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
187 |
|
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
188 |
list_for_each_entry_safe(frame, next, &eoe->tx_queue, queue) { |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
189 |
list_del(&frame->queue); |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
190 |
dev_kfree_skb(frame->skb); |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
191 |
kfree(frame); |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
192 |
} |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
193 |
eoe->tx_queued_frames = 0; |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
194 |
|
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
195 |
spin_unlock_bh(&eoe->tx_queue_lock); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
|
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
200 |
/** |
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
201 |
Sends a frame or the next fragment. |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
202 |
*/ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
203 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
204 |
int ec_eoe_send(ec_eoe_t *eoe /**< EoE handler */) |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
205 |
{ |
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
206 |
size_t remaining_size, current_size, complete_offset; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
207 |
unsigned int last_fragment; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
208 |
uint8_t *data; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
209 |
#if EOE_DEBUG_LEVEL > 1 |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
210 |
unsigned int i; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
211 |
#endif |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
212 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
213 |
remaining_size = eoe->tx_frame->skb->len - eoe->tx_offset; |
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
214 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
215 |
if (remaining_size <= eoe->slave->sii_tx_mailbox_size - 10) { |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
216 |
current_size = remaining_size; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
217 |
last_fragment = 1; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
218 |
} |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
219 |
else { |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
220 |
current_size = ((eoe->slave->sii_tx_mailbox_size - 10) / 32) * 32; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
221 |
last_fragment = 0; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
222 |
} |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
223 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
224 |
if (eoe->tx_fragment_number) { |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
225 |
complete_offset = eoe->tx_offset / 32; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
226 |
} |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
227 |
else { |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
228 |
complete_offset = remaining_size / 32 + 1; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
229 |
} |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
230 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
231 |
#if EOE_DEBUG_LEVEL > 0 |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
232 |
EC_DBG("EoE TX sending %sfragment %i with %i octets (%i)." |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
233 |
" %i frames queued.\n", last_fragment ? "last " : "", |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
234 |
eoe->tx_fragment_number, current_size, complete_offset, |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
235 |
eoe->tx_queued_frames); |
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
236 |
#endif |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
237 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
238 |
#if EOE_DEBUG_LEVEL > 1 |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
239 |
EC_DBG(""); |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
240 |
for (i = 0; i < current_size; i++) { |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
241 |
printk("%02X ", frame->skb->data[eoe->tx_offset + i]); |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
242 |
if ((i + 1) % 16 == 0) { |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
243 |
printk("\n"); |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
244 |
EC_DBG(""); |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
245 |
} |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
246 |
} |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
247 |
printk("\n"); |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
248 |
#endif |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
249 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
250 |
if (!(data = ec_slave_mbox_prepare_send(eoe->slave, &eoe->datagram, |
279
12f48c1cb143
Removed mbox_command out of slave.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
251 |
0x02, current_size + 4))) |
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
252 |
return -1; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
253 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
254 |
EC_WRITE_U8 (data, 0x00); // eoe fragment req. |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
255 |
EC_WRITE_U8 (data + 1, last_fragment); |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
256 |
EC_WRITE_U16(data + 2, ((eoe->tx_fragment_number & 0x3F) | |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
257 |
(complete_offset & 0x3F) << 6 | |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
258 |
(eoe->tx_frame_number & 0x0F) << 12)); |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
259 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
260 |
memcpy(data + 4, eoe->tx_frame->skb->data + eoe->tx_offset, current_size); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
261 |
ec_master_queue_datagram(eoe->slave->master, &eoe->datagram); |
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
262 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
263 |
eoe->tx_offset += current_size; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
264 |
eoe->tx_fragment_number++; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
265 |
return 0; |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
266 |
} |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
267 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
268 |
/*****************************************************************************/ |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
269 |
|
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
270 |
/** |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
271 |
Runs the EoE state machine. |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
272 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
273 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
274 |
void ec_eoe_run(ec_eoe_t *eoe /**< EoE handler */) |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
275 |
{ |
210
1cc6bcb1e6ae
EoE frame receiving; regarding open/stop commands.
Florian Pose <fp@igh-essen.com>
parents:
208
diff
changeset
|
276 |
if (!eoe->opened) return; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
278 |
// call state function |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
279 |
eoe->state(eoe); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
|
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
284 |
/** |
235
f973808540a6
No master locking, if no EoE devices are "up".
Florian Pose <fp@igh-essen.com>
parents:
219
diff
changeset
|
285 |
Returns the state of the device. |
f973808540a6
No master locking, if no EoE devices are "up".
Florian Pose <fp@igh-essen.com>
parents:
219
diff
changeset
|
286 |
\return 1 if the device is "up", 0 if it is "down" |
f973808540a6
No master locking, if no EoE devices are "up".
Florian Pose <fp@igh-essen.com>
parents:
219
diff
changeset
|
287 |
*/ |
f973808540a6
No master locking, if no EoE devices are "up".
Florian Pose <fp@igh-essen.com>
parents:
219
diff
changeset
|
288 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
289 |
unsigned int ec_eoe_active(const ec_eoe_t *eoe /**< EoE handler */) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
290 |
{ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
291 |
return eoe->slave && eoe->opened; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
292 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
293 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
294 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
295 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
296 |
/** |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
297 |
Prints EoE handler information. |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
298 |
*/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
299 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
300 |
void ec_eoe_print(const ec_eoe_t *eoe /**< EoE handler */) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
301 |
{ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
302 |
EC_INFO(" EoE handler %s\n", eoe->dev->name); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
303 |
EC_INFO(" State: %s\n", eoe->opened ? "opened" : "closed"); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
304 |
if (eoe->slave) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
305 |
EC_INFO(" Coupled to slave %i.\n", eoe->slave->ring_position); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
306 |
else |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
307 |
EC_INFO(" Not coupled.\n"); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
308 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
309 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
310 |
/****************************************************************************** |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
311 |
* STATE PROCESSING FUNCTIONS |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
312 |
*****************************************************************************/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
313 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
314 |
/** |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
315 |
State: RX_START. |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
316 |
Starts a new receiving sequence by queueing a datagram that checks the |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
317 |
slave's mailbox for a new EoE datagram. |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
318 |
*/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
319 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
320 |
void ec_eoe_state_rx_start(ec_eoe_t *eoe /**< EoE handler */) |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
321 |
{ |
261
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
322 |
if (!eoe->slave->online || !eoe->slave->master->device->link_state) |
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
323 |
return; |
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
324 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
325 |
ec_slave_mbox_prepare_check(eoe->slave, &eoe->datagram); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
326 |
ec_master_queue_datagram(eoe->slave->master, &eoe->datagram); |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
327 |
eoe->state = ec_eoe_state_rx_check; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
328 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
329 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
330 |
/*****************************************************************************/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
331 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
332 |
/** |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
333 |
State: RX_CHECK. |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
334 |
Processes the checking datagram sent in RX_START and issues a receive |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
335 |
datagram, if new data is available. |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
336 |
*/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
337 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
338 |
void ec_eoe_state_rx_check(ec_eoe_t *eoe /**< EoE handler */) |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
339 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
340 |
if (eoe->datagram.state != EC_CMD_RECEIVED) { |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
341 |
eoe->stats.rx_errors++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
342 |
eoe->state = ec_eoe_state_tx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
343 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
344 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
345 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
346 |
if (!ec_slave_mbox_check(&eoe->datagram)) { |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
347 |
eoe->state = ec_eoe_state_tx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
348 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
349 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
350 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
351 |
ec_slave_mbox_prepare_fetch(eoe->slave, &eoe->datagram); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
352 |
ec_master_queue_datagram(eoe->slave->master, &eoe->datagram); |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
353 |
eoe->state = ec_eoe_state_rx_fetch; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
354 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
355 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
356 |
/*****************************************************************************/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
357 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
358 |
/** |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
359 |
State: RX_FETCH. |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
360 |
Checks if the requested data of RX_CHECK was received and processes the |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
361 |
EoE datagram. |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
362 |
*/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
363 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
364 |
void ec_eoe_state_rx_fetch(ec_eoe_t *eoe /**< EoE handler */) |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
365 |
{ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
366 |
size_t rec_size, data_size; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
367 |
uint8_t *data, frame_type, last_fragment, time_appended; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
368 |
uint8_t frame_number, fragment_offset, fragment_number; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
369 |
off_t offset; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
370 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
371 |
if (eoe->datagram.state != EC_CMD_RECEIVED) { |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
372 |
eoe->stats.rx_errors++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
373 |
eoe->state = ec_eoe_state_tx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
374 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
375 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
376 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
377 |
if (!(data = ec_slave_mbox_fetch(eoe->slave, &eoe->datagram, |
279
12f48c1cb143
Removed mbox_command out of slave.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
378 |
0x02, &rec_size))) { |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
379 |
eoe->stats.rx_errors++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
380 |
eoe->state = ec_eoe_state_tx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
381 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
382 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
383 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
384 |
frame_type = EC_READ_U16(data) & 0x000F; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
385 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
386 |
if (frame_type == 0x00) { // EoE Fragment Request |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
387 |
last_fragment = (EC_READ_U16(data) >> 8) & 0x0001; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
388 |
time_appended = (EC_READ_U16(data) >> 9) & 0x0001; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
389 |
fragment_number = EC_READ_U16(data + 2) & 0x003F; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
390 |
fragment_offset = (EC_READ_U16(data + 2) >> 6) & 0x003F; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
391 |
frame_number = (EC_READ_U16(data + 2) >> 12) & 0x000F; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
392 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
393 |
#if EOE_DEBUG_LEVEL > 0 |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
394 |
EC_DBG("EoE RX fragment %i, offset %i, frame %i%s%s," |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
395 |
" %i octets\n", fragment_number, fragment_offset, |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
396 |
frame_number, |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
397 |
last_fragment ? ", last fragment" : "", |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
398 |
time_appended ? ", + timestamp" : "", |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
399 |
time_appended ? rec_size - 8 : rec_size - 4); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
400 |
#endif |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
401 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
402 |
#if EOE_DEBUG_LEVEL > 1 |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
403 |
EC_DBG(""); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
404 |
for (i = 0; i < rec_size - 4; i++) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
405 |
printk("%02X ", data[i + 4]); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
406 |
if ((i + 1) % 16 == 0) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
407 |
printk("\n"); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
408 |
EC_DBG(""); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
409 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
410 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
411 |
printk("\n"); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
412 |
#endif |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
413 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
414 |
data_size = time_appended ? rec_size - 8 : rec_size - 4; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
415 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
416 |
if (!fragment_number) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
417 |
if (eoe->rx_skb) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
418 |
EC_WARN("EoE RX freeing old socket buffer...\n"); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
419 |
dev_kfree_skb(eoe->rx_skb); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
420 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
421 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
422 |
// new socket buffer |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
423 |
if (!(eoe->rx_skb = dev_alloc_skb(fragment_offset * 32))) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
424 |
if (printk_ratelimit()) |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
425 |
EC_WARN("EoE RX low on mem. frame dropped.\n"); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
426 |
eoe->stats.rx_dropped++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
427 |
eoe->state = ec_eoe_state_tx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
428 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
429 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
430 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
431 |
eoe->rx_skb_offset = 0; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
432 |
eoe->rx_skb_size = fragment_offset * 32; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
433 |
eoe->rx_expected_fragment = 0; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
434 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
435 |
else { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
436 |
if (!eoe->rx_skb) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
437 |
eoe->stats.rx_dropped++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
438 |
eoe->state = ec_eoe_state_tx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
439 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
440 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
441 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
442 |
offset = fragment_offset * 32; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
443 |
if (offset != eoe->rx_skb_offset || |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
444 |
offset + data_size > eoe->rx_skb_size || |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
445 |
fragment_number != eoe->rx_expected_fragment) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
446 |
eoe->stats.rx_errors++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
447 |
eoe->state = ec_eoe_state_tx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
448 |
dev_kfree_skb(eoe->rx_skb); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
449 |
eoe->rx_skb = NULL; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
450 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
451 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
452 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
453 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
454 |
// copy fragment into socket buffer |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
455 |
memcpy(skb_put(eoe->rx_skb, data_size), data + 4, data_size); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
456 |
eoe->rx_skb_offset += data_size; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
457 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
458 |
if (last_fragment) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
459 |
// update statistics |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
460 |
eoe->stats.rx_packets++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
461 |
eoe->stats.rx_bytes += eoe->rx_skb->len; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
462 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
463 |
#if EOE_DEBUG_LEVEL > 0 |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
464 |
EC_DBG("EoE RX frame completed with %u octets.\n", |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
465 |
eoe->rx_skb->len); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
466 |
#endif |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
467 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
468 |
// pass socket buffer to network stack |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
469 |
eoe->rx_skb->dev = eoe->dev; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
470 |
eoe->rx_skb->protocol = eth_type_trans(eoe->rx_skb, eoe->dev); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
471 |
eoe->rx_skb->ip_summed = CHECKSUM_UNNECESSARY; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
472 |
if (netif_rx(eoe->rx_skb)) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
473 |
EC_WARN("EoE RX netif_rx failed.\n"); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
474 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
475 |
eoe->rx_skb = NULL; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
476 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
477 |
eoe->state = ec_eoe_state_tx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
478 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
479 |
else { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
480 |
eoe->rx_expected_fragment++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
481 |
#if EOE_DEBUG_LEVEL > 0 |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
482 |
EC_DBG("EoE RX expecting fragment %i\n", |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
483 |
eoe->rx_expected_fragment); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
484 |
#endif |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
485 |
eoe->state = ec_eoe_state_rx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
486 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
487 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
488 |
else { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
489 |
#if EOE_DEBUG_LEVEL > 0 |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
490 |
EC_DBG("other frame received.\n"); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
491 |
#endif |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
492 |
eoe->stats.rx_dropped++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
493 |
eoe->state = ec_eoe_state_tx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
494 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
495 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
496 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
497 |
/*****************************************************************************/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
498 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
499 |
/** |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
500 |
State: TX START. |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
501 |
Starts a new transmit sequence. If no data is available, a new receive |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
502 |
sequence is started instead. |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
503 |
*/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
504 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
505 |
void ec_eoe_state_tx_start(ec_eoe_t *eoe /**< EoE handler */) |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
506 |
{ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
507 |
#if EOE_DEBUG_LEVEL > 0 |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
508 |
unsigned int wakeup; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
509 |
#endif |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
510 |
|
261
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
511 |
if (!eoe->slave->online || !eoe->slave->master->device->link_state) |
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
512 |
return; |
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
513 |
|
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
514 |
spin_lock_bh(&eoe->tx_queue_lock); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
515 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
516 |
if (!eoe->tx_queued_frames || list_empty(&eoe->tx_queue)) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
517 |
spin_unlock_bh(&eoe->tx_queue_lock); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
518 |
// no data available. |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
519 |
// start a new receive immediately. |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
520 |
ec_eoe_state_rx_start(eoe); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
521 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
522 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
523 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
524 |
// take the first frame out of the queue |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
525 |
eoe->tx_frame = list_entry(eoe->tx_queue.next, ec_eoe_frame_t, queue); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
526 |
list_del(&eoe->tx_frame->queue); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
527 |
if (!eoe->tx_queue_active && |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
528 |
eoe->tx_queued_frames == EC_EOE_TX_QUEUE_SIZE / 2) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
529 |
netif_wake_queue(eoe->dev); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
530 |
eoe->tx_queue_active = 1; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
531 |
#if EOE_DEBUG_LEVEL > 0 |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
532 |
wakeup = 1; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
533 |
#endif |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
534 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
535 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
536 |
eoe->tx_queued_frames--; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
537 |
spin_unlock_bh(&eoe->tx_queue_lock); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
538 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
539 |
eoe->tx_frame_number++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
540 |
eoe->tx_frame_number %= 16; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
541 |
eoe->tx_fragment_number = 0; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
542 |
eoe->tx_offset = 0; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
543 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
544 |
if (ec_eoe_send(eoe)) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
545 |
dev_kfree_skb(eoe->tx_frame->skb); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
546 |
kfree(eoe->tx_frame); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
547 |
eoe->tx_frame = NULL; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
548 |
eoe->stats.tx_errors++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
549 |
eoe->state = ec_eoe_state_rx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
550 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
551 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
552 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
553 |
#if EOE_DEBUG_LEVEL > 0 |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
554 |
if (wakeup) EC_DBG("waking up TX queue...\n"); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
555 |
#endif |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
556 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
557 |
eoe->state = ec_eoe_state_tx_sent; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
558 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
559 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
560 |
/*****************************************************************************/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
561 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
562 |
/** |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
563 |
State: TX SENT. |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
564 |
Checks is the previous transmit datagram succeded and sends the next |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
565 |
fragment, if necessary. |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
566 |
*/ |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
567 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
568 |
void ec_eoe_state_tx_sent(ec_eoe_t *eoe /**< EoE handler */) |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
569 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
570 |
if (eoe->datagram.state != EC_CMD_RECEIVED) { |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
571 |
eoe->stats.tx_errors++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
572 |
eoe->state = ec_eoe_state_rx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
573 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
574 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
575 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
576 |
if (eoe->datagram.working_counter != 1) { |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
577 |
eoe->stats.tx_errors++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
578 |
eoe->state = ec_eoe_state_rx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
579 |
return; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
580 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
581 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
582 |
// frame completely sent |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
583 |
if (eoe->tx_offset >= eoe->tx_frame->skb->len) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
584 |
eoe->stats.tx_packets++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
585 |
eoe->stats.tx_bytes += eoe->tx_frame->skb->len; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
586 |
dev_kfree_skb(eoe->tx_frame->skb); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
587 |
kfree(eoe->tx_frame); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
588 |
eoe->tx_frame = NULL; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
589 |
eoe->state = ec_eoe_state_rx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
590 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
591 |
else { // send next fragment |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
592 |
if (ec_eoe_send(eoe)) { |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
593 |
dev_kfree_skb(eoe->tx_frame->skb); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
594 |
kfree(eoe->tx_frame); |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
595 |
eoe->tx_frame = NULL; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
596 |
eoe->stats.tx_errors++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
597 |
eoe->state = ec_eoe_state_rx_start; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
598 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
599 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
600 |
} |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
601 |
|
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
602 |
/****************************************************************************** |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
603 |
* NET_DEVICE functions |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
604 |
*****************************************************************************/ |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
605 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
606 |
/** |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
607 |
Opens the virtual network device. |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
608 |
*/ |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
609 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
610 |
int ec_eoedev_open(struct net_device *dev /**< EoE net_device */) |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
611 |
{ |
213
8d723b9833a9
removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents:
212
diff
changeset
|
612 |
ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev)); |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
613 |
ec_eoe_flush(eoe); |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
614 |
eoe->opened = 1; |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
615 |
netif_start_queue(dev); |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
616 |
eoe->tx_queue_active = 1; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
617 |
EC_INFO("%s opened.\n", dev->name); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
618 |
if (!eoe->slave) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
619 |
EC_WARN("device %s is not coupled to any EoE slave!\n", dev->name); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
620 |
else { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
621 |
eoe->slave->requested_state = EC_SLAVE_STATE_OP; |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
622 |
eoe->slave->error_flag = 0; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
623 |
} |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
624 |
return 0; |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
625 |
} |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
626 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
627 |
/*****************************************************************************/ |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
628 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
629 |
/** |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
630 |
Stops the virtual network device. |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
631 |
*/ |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
632 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
633 |
int ec_eoedev_stop(struct net_device *dev /**< EoE net_device */) |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
634 |
{ |
213
8d723b9833a9
removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents:
212
diff
changeset
|
635 |
ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev)); |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
636 |
netif_stop_queue(dev); |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
637 |
eoe->tx_queue_active = 0; |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
638 |
eoe->opened = 0; |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
639 |
ec_eoe_flush(eoe); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
640 |
EC_INFO("%s stopped.\n", dev->name); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
641 |
if (!eoe->slave) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
642 |
EC_WARN("device %s is not coupled to any EoE slave!\n", dev->name); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
643 |
else { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
644 |
eoe->slave->requested_state = EC_SLAVE_STATE_INIT; |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
645 |
eoe->slave->error_flag = 0; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
646 |
} |
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
647 |
return 0; |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
648 |
} |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
649 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
650 |
/*****************************************************************************/ |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
651 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
652 |
/** |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
653 |
Transmits data via the virtual network device. |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
654 |
*/ |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
655 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
656 |
int ec_eoedev_tx(struct sk_buff *skb, /**< transmit socket buffer */ |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
657 |
struct net_device *dev /**< EoE net_device */ |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
658 |
) |
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
659 |
{ |
213
8d723b9833a9
removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents:
212
diff
changeset
|
660 |
ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev)); |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
661 |
ec_eoe_frame_t *frame; |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
662 |
|
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
663 |
#if 0 |
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
664 |
if (skb->len > eoe->slave->sii_tx_mailbox_size - 10) { |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
665 |
EC_WARN("EoE TX frame (%i octets) exceeds MTU. dropping.\n", skb->len); |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
666 |
dev_kfree_skb(skb); |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
667 |
eoe->stats.tx_dropped++; |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
668 |
return 0; |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
669 |
} |
217
dcfd406e7786
EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents:
216
diff
changeset
|
670 |
#endif |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
671 |
|
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
672 |
if (!(frame = |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
673 |
(ec_eoe_frame_t *) kmalloc(sizeof(ec_eoe_frame_t), GFP_ATOMIC))) { |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
674 |
if (printk_ratelimit()) |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
675 |
EC_WARN("EoE TX: low on mem. frame dropped.\n"); |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
676 |
return 1; |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
677 |
} |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
678 |
|
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
679 |
frame->skb = skb; |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
680 |
|
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
681 |
spin_lock_bh(&eoe->tx_queue_lock); |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
682 |
list_add_tail(&frame->queue, &eoe->tx_queue); |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
683 |
eoe->tx_queued_frames++; |
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
684 |
if (eoe->tx_queued_frames == EC_EOE_TX_QUEUE_SIZE) { |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
685 |
netif_stop_queue(dev); |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
686 |
eoe->tx_queue_active = 0; |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
687 |
} |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
688 |
spin_unlock_bh(&eoe->tx_queue_lock); |
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
689 |
|
215
b021aa6eee38
EoE: TCP traffic possible; TX fragmenting to do.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
690 |
#if EOE_DEBUG_LEVEL > 0 |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
691 |
EC_DBG("EoE TX queued frame with %i octets (%i frames queued).\n", |
218
80fb87518f3d
EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents:
217
diff
changeset
|
692 |
skb->len, eoe->tx_queued_frames); |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
693 |
if (!eoe->tx_queue_active) |
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
694 |
EC_WARN("EoE TX queue is now full.\n"); |
215
b021aa6eee38
EoE: TCP traffic possible; TX fragmenting to do.
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
695 |
#endif |
214
8beb86af5ed0
EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents:
213
diff
changeset
|
696 |
|
203
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
697 |
return 0; |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
698 |
} |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
699 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
700 |
/*****************************************************************************/ |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
701 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
702 |
/** |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
703 |
Gets statistics about the virtual network device. |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
704 |
*/ |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
705 |
|
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
706 |
struct net_device_stats *ec_eoedev_stats(struct net_device *dev |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
707 |
/**< EoE net_device */) |
c1f305e339c6
EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
708 |
{ |
213
8d723b9833a9
removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents:
212
diff
changeset
|
709 |
ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev)); |
212
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
710 |
return &eoe->stats; |
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
711 |
} |
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
712 |
|
82980deb8b00
moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents:
210
diff
changeset
|
713 |
/*****************************************************************************/ |