author | Florian Pose <fp@igh-essen.com> |
Wed, 18 Jun 2008 11:16:30 +0000 | |
changeset 1025 | ae175095f09a |
parent 1011 | a0759d0dded4 |
child 1029 | 61ffe5f22306 |
permissions | -rw-r--r-- |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
1 |
/****************************************************************************** |
0 | 2 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
3 |
* $Id$ |
0 | 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:
231
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:
231
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:
231
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:
231
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:
231
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:
231
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:
231
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:
231
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:
231
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:
231
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
231
diff
changeset
|
31 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
32 |
*****************************************************************************/ |
0 | 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 |
EtherCAT device methods. |
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 |
|
24
d417dd9bdc2f
Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents:
23
diff
changeset
|
41 |
#include <linux/module.h> |
0 | 42 |
#include <linux/skbuff.h> |
43 |
#include <linux/if_ether.h> |
|
44 |
#include <linux/netdevice.h> |
|
45 |
||
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
42
diff
changeset
|
46 |
#include "device.h" |
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
47 |
#include "master.h" |
0 | 48 |
|
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
49 |
#ifdef EC_DEBUG_RING |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
50 |
#define timersub(a, b, result) \ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
51 |
do { \ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
52 |
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
53 |
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
54 |
if ((result)->tv_usec < 0) { \ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
55 |
--(result)->tv_sec; \ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
56 |
(result)->tv_usec += 1000000; \ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
57 |
} \ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
58 |
} while (0) |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
59 |
#endif |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
60 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
61 |
/*****************************************************************************/ |
0 | 62 |
|
1011 | 63 |
/** Constructor. |
64 |
* |
|
65 |
* \return 0 in case of success, else < 0 |
|
66 |
*/ |
|
67 |
int ec_device_init( |
|
68 |
ec_device_t *device, /**< EtherCAT device */ |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
69 |
ec_master_t *master /**< master owning the device */ |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
70 |
) |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
71 |
{ |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
72 |
unsigned int i; |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
73 |
struct ethhdr *eth; |
687
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
74 |
#ifdef EC_DEBUG_IF |
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
75 |
char ifname[10]; |
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
76 |
char mb = 'x'; |
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
77 |
#endif |
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
78 |
#ifdef EC_DEBUG_RING |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
79 |
device->debug_frame_index = 0; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
80 |
device->debug_frame_count = 0; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
81 |
#endif |
687
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
82 |
|
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
83 |
device->master = master; |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
84 |
device->tx_ring_index = 0; |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
85 |
|
679
62fc387ec928
Added --enable-dummy; renamed EC_DBG_IF to EC_DEBUG_IF, ENABLE_DEBUG_IF
Florian Pose <fp@igh-essen.com>
parents:
670
diff
changeset
|
86 |
#ifdef EC_DEBUG_IF |
687
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
87 |
if (device == &master->main_device) |
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
88 |
mb = 'm'; |
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
89 |
else if (device == &master->backup_device) |
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
90 |
mb = 'b'; |
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
91 |
|
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
92 |
sprintf(ifname, "ecdbg%c%u", mb, master->index); |
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
93 |
|
6de97f276423
Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents:
679
diff
changeset
|
94 |
if (ec_debug_init(&device->dbg, ifname)) { |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
95 |
EC_ERR("Failed to init debug device!\n"); |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
96 |
goto out_return; |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
97 |
} |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
98 |
#endif |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
99 |
|
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
100 |
for (i = 0; i < EC_TX_RING_SIZE; i++) |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
101 |
device->tx_skb[i] = NULL; |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
102 |
|
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
103 |
for (i = 0; i < EC_TX_RING_SIZE; i++) { |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
104 |
if (!(device->tx_skb[i] = dev_alloc_skb(ETH_FRAME_LEN))) { |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
105 |
EC_ERR("Error allocating device socket buffer!\n"); |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
106 |
goto out_tx_ring; |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
107 |
} |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
108 |
|
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
109 |
// add Ethernet-II-header |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
110 |
skb_reserve(device->tx_skb[i], ETH_HLEN); |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
111 |
eth = (struct ethhdr *) skb_push(device->tx_skb[i], ETH_HLEN); |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
112 |
eth->h_proto = htons(0x88A4); |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
113 |
memset(eth->h_dest, 0xFF, ETH_ALEN); |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
114 |
} |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
115 |
|
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
116 |
ec_device_detach(device); // resets remaining fields |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
117 |
return 0; |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
118 |
|
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
119 |
out_tx_ring: |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
120 |
for (i = 0; i < EC_TX_RING_SIZE; i++) |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
121 |
if (device->tx_skb[i]) |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
122 |
dev_kfree_skb(device->tx_skb[i]); |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
123 |
#ifdef EC_DEBUG_IF |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
124 |
ec_debug_clear(&device->dbg); |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
125 |
out_return: |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
126 |
#endif |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
127 |
return -1; |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
128 |
} |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
129 |
|
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
130 |
/*****************************************************************************/ |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
131 |
|
1011 | 132 |
/** Destuctor. |
133 |
*/ |
|
134 |
void ec_device_clear( |
|
135 |
ec_device_t *device /**< EtherCAT device */ |
|
136 |
) |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
137 |
{ |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
138 |
unsigned int i; |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
139 |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
140 |
if (device->open) ec_device_close(device); |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
141 |
for (i = 0; i < EC_TX_RING_SIZE; i++) |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
142 |
dev_kfree_skb(device->tx_skb[i]); |
679
62fc387ec928
Added --enable-dummy; renamed EC_DBG_IF to EC_DEBUG_IF, ENABLE_DEBUG_IF
Florian Pose <fp@igh-essen.com>
parents:
670
diff
changeset
|
143 |
#ifdef EC_DEBUG_IF |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
144 |
ec_debug_clear(&device->dbg); |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
145 |
#endif |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
146 |
} |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
147 |
|
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
148 |
/*****************************************************************************/ |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
149 |
|
1011 | 150 |
/** Associate with net_device. |
151 |
*/ |
|
152 |
void ec_device_attach( |
|
153 |
ec_device_t *device, /**< EtherCAT device */ |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
154 |
struct net_device *net_dev, /**< net_device structure */ |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
155 |
ec_pollfunc_t poll, /**< pointer to device's poll function */ |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
156 |
struct module *module /**< the device's module */ |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
157 |
) |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
158 |
{ |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
159 |
unsigned int i; |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
160 |
struct ethhdr *eth; |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
161 |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
162 |
ec_device_detach(device); // resets fields |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
163 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
164 |
device->dev = net_dev; |
533
acdd1f9ef7ab
Replaced ec_isr_t by ec_pollfunc_t; added poll function s in network drivers.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
165 |
device->poll = poll; |
539
7bb92fca28ef
Fixed invalid module pointer in device structure.
Florian Pose <fp@igh-essen.com>
parents:
533
diff
changeset
|
166 |
device->module = module; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
167 |
|
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
168 |
for (i = 0; i < EC_TX_RING_SIZE; i++) { |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
169 |
device->tx_skb[i]->dev = net_dev; |
759
fe32d4cdc9c3
Fixed source MAC address setting bug.
Florian Pose <fp@igh-essen.com>
parents:
725
diff
changeset
|
170 |
eth = (struct ethhdr *) (device->tx_skb[i]->data); |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
171 |
memcpy(eth->h_source, net_dev->dev_addr, ETH_ALEN); |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
172 |
} |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
173 |
} |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
174 |
|
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
175 |
/*****************************************************************************/ |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
176 |
|
1011 | 177 |
/** Disconnect from net_device. |
178 |
*/ |
|
179 |
void ec_device_detach( |
|
180 |
ec_device_t *device /**< EtherCAT device */ |
|
181 |
) |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
182 |
{ |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
183 |
unsigned int i; |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
184 |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
185 |
device->dev = NULL; |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
186 |
device->poll = NULL; |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
574
diff
changeset
|
187 |
device->module = NULL; |
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
188 |
device->open = 0; |
96 | 189 |
device->link_state = 0; // down |
493 | 190 |
device->tx_count = 0; |
191 |
device->rx_count = 0; |
|
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
192 |
for (i = 0; i < EC_TX_RING_SIZE; i++) |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
193 |
device->tx_skb[i]->dev = NULL; |
0 | 194 |
} |
195 |
||
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
196 |
/*****************************************************************************/ |
0 | 197 |
|
1011 | 198 |
/** Opens the EtherCAT device. |
199 |
* |
|
200 |
* \return 0 in case of success, else < 0 |
|
201 |
*/ |
|
202 |
int ec_device_open( |
|
203 |
ec_device_t *device /**< EtherCAT device */ |
|
204 |
) |
|
0 | 205 |
{ |
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
206 |
if (!device->dev) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
78
diff
changeset
|
207 |
EC_ERR("No net_device to open!\n"); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
208 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
209 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
210 |
|
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
211 |
if (device->open) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
78
diff
changeset
|
212 |
EC_WARN("Device already opened!\n"); |
91
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
84
diff
changeset
|
213 |
return 0; |
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
84
diff
changeset
|
214 |
} |
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
84
diff
changeset
|
215 |
|
96 | 216 |
device->link_state = 0; |
493 | 217 |
device->tx_count = 0; |
218 |
device->rx_count = 0; |
|
91
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
84
diff
changeset
|
219 |
|
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
84
diff
changeset
|
220 |
if (device->dev->open(device->dev) == 0) device->open = 1; |
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
221 |
|
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
222 |
return device->open ? 0 : -1; |
0 | 223 |
} |
224 |
||
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
225 |
/*****************************************************************************/ |
0 | 226 |
|
1011 | 227 |
/** Stops the EtherCAT device. |
228 |
* |
|
229 |
* \return 0 in case of success, else < 0 |
|
230 |
*/ |
|
231 |
int ec_device_close( |
|
232 |
ec_device_t *device /**< EtherCAT device */ |
|
233 |
) |
|
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
234 |
{ |
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
235 |
if (!device->dev) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
78
diff
changeset
|
236 |
EC_ERR("No device to close!\n"); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
237 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
238 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
239 |
|
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
240 |
if (!device->open) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
78
diff
changeset
|
241 |
EC_WARN("Device already closed!\n"); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
242 |
return 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
243 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
244 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
245 |
if (device->dev->stop(device->dev) == 0) device->open = 0; |
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
246 |
|
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
247 |
return !device->open ? 0 : -1; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
248 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
249 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
250 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
251 |
|
1011 | 252 |
/** Returns a pointer to the device's transmit memory. |
253 |
* |
|
254 |
* \return pointer to the TX socket buffer |
|
255 |
*/ |
|
256 |
uint8_t *ec_device_tx_data( |
|
257 |
ec_device_t *device /**< EtherCAT device */ |
|
258 |
) |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
259 |
{ |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
260 |
/* cycle through socket buffers, because otherwise there is a race |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
261 |
* condition, if multiple frames are sent and the DMA is not scheduled in |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
262 |
* between. */ |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
263 |
device->tx_ring_index++; |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
264 |
device->tx_ring_index %= EC_TX_RING_SIZE; |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
265 |
return device->tx_skb[device->tx_ring_index]->data + ETH_HLEN; |
0 | 266 |
} |
267 |
||
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
268 |
/*****************************************************************************/ |
0 | 269 |
|
1011 | 270 |
/** Sends the content of the transmit socket buffer. |
271 |
* |
|
272 |
* Cuts the socket buffer content to the (now known) size, and calls the |
|
273 |
* start_xmit() function of the assigned net_device. |
|
274 |
*/ |
|
275 |
void ec_device_send( |
|
276 |
ec_device_t *device, /**< EtherCAT device */ |
|
277 |
size_t size /**< number of bytes to send */ |
|
278 |
) |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
279 |
{ |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
280 |
struct sk_buff *skb = device->tx_skb[device->tx_ring_index]; |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
281 |
|
97
e6264685dd7b
Link-Down-Verhalten verbessert.
Florian Pose <fp@igh-essen.com>
parents:
96
diff
changeset
|
282 |
if (unlikely(!device->link_state)) // Link down |
96 | 283 |
return; |
284 |
||
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
285 |
// set the right length for the data |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
286 |
skb->len = ETH_HLEN + size; |
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
287 |
|
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
288 |
if (unlikely(device->master->debug_level > 1)) { |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
289 |
EC_DBG("sending frame:\n"); |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
290 |
ec_print_data(skb->data + ETH_HLEN, size); |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
291 |
} |
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
292 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
293 |
// start sending |
725
8bacb27f3aa2
Send frame to debug-if and debug-ring only when transmitted
Florian Pose <fp@igh-essen.com>
parents:
693
diff
changeset
|
294 |
if (device->dev->hard_start_xmit(skb, device->dev) == NETDEV_TX_OK) { |
8bacb27f3aa2
Send frame to debug-if and debug-ring only when transmitted
Florian Pose <fp@igh-essen.com>
parents:
693
diff
changeset
|
295 |
device->tx_count++; |
8bacb27f3aa2
Send frame to debug-if and debug-ring only when transmitted
Florian Pose <fp@igh-essen.com>
parents:
693
diff
changeset
|
296 |
#ifdef EC_DEBUG_IF |
8bacb27f3aa2
Send frame to debug-if and debug-ring only when transmitted
Florian Pose <fp@igh-essen.com>
parents:
693
diff
changeset
|
297 |
ec_debug_send(&device->dbg, skb->data, ETH_HLEN + size); |
8bacb27f3aa2
Send frame to debug-if and debug-ring only when transmitted
Florian Pose <fp@igh-essen.com>
parents:
693
diff
changeset
|
298 |
#endif |
8bacb27f3aa2
Send frame to debug-if and debug-ring only when transmitted
Florian Pose <fp@igh-essen.com>
parents:
693
diff
changeset
|
299 |
#ifdef EC_DEBUG_RING |
8bacb27f3aa2
Send frame to debug-if and debug-ring only when transmitted
Florian Pose <fp@igh-essen.com>
parents:
693
diff
changeset
|
300 |
ec_device_debug_ring_append( |
8bacb27f3aa2
Send frame to debug-if and debug-ring only when transmitted
Florian Pose <fp@igh-essen.com>
parents:
693
diff
changeset
|
301 |
device, TX, skb->data + ETH_HLEN, size); |
8bacb27f3aa2
Send frame to debug-if and debug-ring only when transmitted
Florian Pose <fp@igh-essen.com>
parents:
693
diff
changeset
|
302 |
#endif |
8bacb27f3aa2
Send frame to debug-if and debug-ring only when transmitted
Florian Pose <fp@igh-essen.com>
parents:
693
diff
changeset
|
303 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
304 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
305 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
306 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
307 |
|
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
308 |
#ifdef EC_DEBUG_RING |
1011 | 309 |
/** Appends frame data to the debug ring. |
310 |
*/ |
|
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
311 |
void ec_device_debug_ring_append( |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
312 |
ec_device_t *device, /**< EtherCAT device */ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
313 |
ec_debug_frame_dir_t dir, /**< direction */ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
314 |
const void *data, /**< frame data */ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
315 |
size_t size /**< data size */ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
316 |
) |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
317 |
{ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
318 |
ec_debug_frame_t *df = &device->debug_frames[device->debug_frame_index]; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
319 |
|
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
320 |
df->dir = dir; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
321 |
if (dir == TX) |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
322 |
do_gettimeofday(&df->t); |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
323 |
else |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
324 |
df->t = device->timeval_poll; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
325 |
memcpy(df->data, data, size); |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
326 |
df->data_size = size; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
327 |
|
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
328 |
device->debug_frame_index++; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
329 |
device->debug_frame_index %= EC_DEBUG_RING_SIZE; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
330 |
if (unlikely(device->debug_frame_count < EC_DEBUG_RING_SIZE)) |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
331 |
device->debug_frame_count++; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
332 |
} |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
333 |
|
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
334 |
/*****************************************************************************/ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
335 |
|
1011 | 336 |
/** Outputs the debug ring. |
337 |
*/ |
|
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
338 |
void ec_device_debug_ring_print( |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
339 |
const ec_device_t *device /**< EtherCAT device */ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
340 |
) |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
341 |
{ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
342 |
int i; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
343 |
unsigned int ring_index; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
344 |
const ec_debug_frame_t *df; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
345 |
struct timeval t0, diff; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
346 |
|
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
347 |
// calculate index of the newest frame in the ring to get its time |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
348 |
ring_index = (device->debug_frame_index + EC_DEBUG_RING_SIZE - 1) |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
349 |
% EC_DEBUG_RING_SIZE; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
350 |
t0 = device->debug_frames[ring_index].t; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
351 |
|
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
759
diff
changeset
|
352 |
EC_DBG("Debug ring %u:\n", ring_index); |
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
353 |
|
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
354 |
// calculate index of the oldest frame in the ring |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
355 |
ring_index = (device->debug_frame_index + EC_DEBUG_RING_SIZE |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
356 |
- device->debug_frame_count) % EC_DEBUG_RING_SIZE; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
357 |
|
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
358 |
for (i = 0; i < device->debug_frame_count; i++) { |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
359 |
df = &device->debug_frames[ring_index]; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
360 |
timersub(&t0, &df->t, &diff); |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
361 |
|
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
759
diff
changeset
|
362 |
EC_DBG("Frame %u, dt=%u.%06u s, %s:\n", |
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
363 |
i + 1 - device->debug_frame_count, |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
364 |
(unsigned int) diff.tv_sec, |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
365 |
(unsigned int) diff.tv_usec, |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
366 |
(df->dir == TX) ? "TX" : "RX"); |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
367 |
ec_print_data(df->data, df->data_size); |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
368 |
|
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
369 |
ring_index++; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
370 |
ring_index %= EC_DEBUG_RING_SIZE; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
371 |
} |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
372 |
} |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
373 |
#endif |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
374 |
|
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
375 |
/*****************************************************************************/ |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
376 |
|
1011 | 377 |
/** Calls the poll function of the assigned net_device. |
378 |
* |
|
379 |
* The master itself works without using interrupts. Therefore the processing |
|
380 |
* of received data and status changes of the network device has to be |
|
381 |
* done by the master calling the ISR "manually". |
|
382 |
*/ |
|
383 |
void ec_device_poll( |
|
384 |
ec_device_t *device /**< EtherCAT device */ |
|
385 |
) |
|
533
acdd1f9ef7ab
Replaced ec_isr_t by ec_pollfunc_t; added poll function s in network drivers.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
386 |
{ |
acdd1f9ef7ab
Replaced ec_isr_t by ec_pollfunc_t; added poll function s in network drivers.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
387 |
device->cycles_poll = get_cycles(); |
acdd1f9ef7ab
Replaced ec_isr_t by ec_pollfunc_t; added poll function s in network drivers.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
388 |
device->jiffies_poll = jiffies; |
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
389 |
#ifdef EC_DEBUG_RING |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
390 |
do_gettimeofday(&device->timeval_poll); |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
391 |
#endif |
533
acdd1f9ef7ab
Replaced ec_isr_t by ec_pollfunc_t; added poll function s in network drivers.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
392 |
device->poll(device->dev); |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
393 |
} |
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
394 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
42
diff
changeset
|
395 |
/****************************************************************************** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
396 |
* Device interface |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
42
diff
changeset
|
397 |
*****************************************************************************/ |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
42
diff
changeset
|
398 |
|
1011 | 399 |
/** Withdraws an EtherCAT device from the master. |
400 |
* |
|
401 |
* The device is disconnected from the master and all device ressources |
|
402 |
* are freed. |
|
403 |
* |
|
404 |
* \attention Before calling this function, the ecdev_stop() function has |
|
405 |
* to be called, to be sure that the master does not use the device |
|
406 |
* any more. |
|
407 |
* \ingroup DeviceInterface |
|
408 |
*/ |
|
409 |
void ecdev_withdraw(ec_device_t *device /**< EtherCAT device */) |
|
410 |
{ |
|
411 |
ec_master_t *master = device->master; |
|
412 |
char str[20]; |
|
413 |
||
414 |
ec_mac_print(device->dev->dev_addr, str); |
|
415 |
EC_INFO("Master %u releasing main device %s.\n", master->index, str); |
|
416 |
||
417 |
down(&master->device_sem); |
|
418 |
ec_device_detach(device); |
|
419 |
up(&master->device_sem); |
|
420 |
} |
|
421 |
||
422 |
/*****************************************************************************/ |
|
423 |
||
424 |
/** Opens the network device and makes the master enter IDLE mode. |
|
425 |
* |
|
426 |
* \return 0 on success, else < 0 |
|
427 |
* \ingroup DeviceInterface |
|
428 |
*/ |
|
429 |
int ecdev_open(ec_device_t *device /**< EtherCAT device */) |
|
430 |
{ |
|
431 |
if (ec_device_open(device)) { |
|
432 |
EC_ERR("Failed to open device!\n"); |
|
433 |
return -1; |
|
434 |
} |
|
435 |
||
436 |
if (ec_master_enter_idle_mode(device->master)) { |
|
437 |
EC_ERR("Failed to enter idle mode!\n"); |
|
438 |
return -1; |
|
439 |
} |
|
440 |
||
441 |
return 0; |
|
442 |
} |
|
443 |
||
444 |
/*****************************************************************************/ |
|
445 |
||
446 |
/** Makes the master leave IDLE mode and closes the network device. |
|
447 |
* |
|
448 |
* \return 0 on success, else < 0 |
|
449 |
* \ingroup DeviceInterface |
|
450 |
*/ |
|
451 |
void ecdev_close(ec_device_t *device /**< EtherCAT device */) |
|
452 |
{ |
|
453 |
ec_master_leave_idle_mode(device->master); |
|
454 |
||
455 |
if (ec_device_close(device)) |
|
456 |
EC_WARN("Failed to close device!\n"); |
|
457 |
} |
|
458 |
||
459 |
/*****************************************************************************/ |
|
460 |
||
461 |
/** Accepts a received frame. |
|
462 |
* |
|
463 |
* Forwards the received data to the master. The master will analyze the frame |
|
464 |
* and dispatch the received commands to the sending instances. |
|
465 |
* |
|
466 |
* \ingroup DeviceInterface |
|
467 |
*/ |
|
468 |
void ecdev_receive( |
|
469 |
ec_device_t *device, /**< EtherCAT device */ |
|
470 |
const void *data, /**< pointer to received data */ |
|
471 |
size_t size /**< number of bytes received */ |
|
472 |
) |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
70
diff
changeset
|
473 |
{ |
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
474 |
const void *ec_data = data + ETH_HLEN; |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
475 |
size_t ec_size = size - ETH_HLEN; |
493 | 476 |
device->rx_count++; |
477 |
||
78
3d74183d6c6b
Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
478 |
if (unlikely(device->master->debug_level > 1)) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
78
diff
changeset
|
479 |
EC_DBG("Received frame:\n"); |
693
e341f1788608
Switched to tx socket buffer ring to avoid race conditions when multiple
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
480 |
ec_print_data(ec_data, ec_size); |
231
767548c75bf3
Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
211
diff
changeset
|
481 |
} |
767548c75bf3
Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
211
diff
changeset
|
482 |
|
679
62fc387ec928
Added --enable-dummy; renamed EC_DBG_IF to EC_DEBUG_IF, ENABLE_DEBUG_IF
Florian Pose <fp@igh-essen.com>
parents:
670
diff
changeset
|
483 |
#ifdef EC_DEBUG_IF |
231
767548c75bf3
Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
211
diff
changeset
|
484 |
ec_debug_send(&device->dbg, data, size); |
392
eaee3c8d6ae0
Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents:
331
diff
changeset
|
485 |
#endif |
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
486 |
#ifdef EC_DEBUG_RING |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
487 |
ec_device_debug_ring_append(device, RX, ec_data, ec_size); |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
488 |
#endif |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
489 |
|
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
687
diff
changeset
|
490 |
ec_master_receive_datagrams(device->master, ec_data, ec_size); |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
42
diff
changeset
|
491 |
} |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
42
diff
changeset
|
492 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
42
diff
changeset
|
493 |
/*****************************************************************************/ |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
42
diff
changeset
|
494 |
|
1011 | 495 |
/** Sets a new link state. |
496 |
* |
|
497 |
* If the device notifies the master about the link being down, the master |
|
498 |
* will not try to send frames using this device. |
|
499 |
* |
|
500 |
* \ingroup DeviceInterface |
|
501 |
*/ |
|
502 |
void ecdev_set_link( |
|
503 |
ec_device_t *device, /**< EtherCAT device */ |
|
670
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
504 |
uint8_t state /**< new link state */ |
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
505 |
) |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
506 |
{ |
191 | 507 |
if (unlikely(!device)) { |
1011 | 508 |
EC_WARN("ecdev_set_link(): No device!\n"); |
191 | 509 |
return; |
510 |
} |
|
511 |
||
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
512 |
if (likely(state != device->link_state)) { |
96 | 513 |
device->link_state = state; |
514 |
EC_INFO("Link state changed to %s.\n", (state ? "UP" : "DOWN")); |
|
515 |
} |
|
516 |
} |
|
517 |
||
518 |
/*****************************************************************************/ |
|
519 |
||
1011 | 520 |
/** Reads the link state. |
521 |
* |
|
522 |
* \ingroup DeviceInterface |
|
523 |
*/ |
|
524 |
uint8_t ecdev_get_link( |
|
525 |
const ec_device_t *device /**< EtherCAT device */ |
|
526 |
) |
|
670
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
527 |
{ |
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
528 |
if (unlikely(!device)) { |
1011 | 529 |
EC_WARN("ecdev_get_link(): No device!\n"); |
670
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
530 |
return 0; |
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
531 |
} |
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
532 |
|
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
533 |
return device->link_state; |
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
534 |
} |
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
535 |
|
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
536 |
/*****************************************************************************/ |
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
537 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
538 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
539 |
|
1011 | 540 |
EXPORT_SYMBOL(ecdev_withdraw); |
541 |
EXPORT_SYMBOL(ecdev_open); |
|
542 |
EXPORT_SYMBOL(ecdev_close); |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
543 |
EXPORT_SYMBOL(ecdev_receive); |
670
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
544 |
EXPORT_SYMBOL(ecdev_get_link); |
f57de4585a5f
Replaced ecdev_link_state() with ecdev_set_link(); added
Florian Pose <fp@igh-essen.com>
parents:
590
diff
changeset
|
545 |
EXPORT_SYMBOL(ecdev_set_link); |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
546 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
547 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
548 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
549 |
/*****************************************************************************/ |