master/device.c
author Florian Pose <fp@igh-essen.com>
Tue, 20 Feb 2007 09:43:23 +0000
changeset 575 9a2121b500b1
parent 574 609e58ece96a
child 579 17c6fd3b076e
permissions -rw-r--r--
Layed out device ID functionality in own files.
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
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     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
05c992bf5847 trunk, tags und branches
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: 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
05c992bf5847 trunk, tags und branches
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
   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
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include <linux/skbuff.h>
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include <linux/if_ether.h>
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include <linux/netdevice.h>
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    49
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    52
   Device constructor.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    53
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    54
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    55
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    56
int ec_device_init(ec_device_t *device, /**< EtherCAT device */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    57
                   ec_master_t *master, /**< master owning the device */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    58
                   struct net_device *net_dev, /**< net_device structure */
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
    59
                   ec_pollfunc_t poll, /**< pointer to device's poll function */
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
    60
                   struct module *module /**< the device's module */
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    61
                   )
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    62
{
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    63
    struct ethhdr *eth;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    64
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    65
    device->master = master;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    66
    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
    67
    device->poll = poll;
539
7bb92fca28ef Fixed invalid module pointer in device structure.
Florian Pose <fp@igh-essen.com>
parents: 533
diff changeset
    68
    device->module = module;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    69
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    70
    device->open = 0;
96
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    71
    device->link_state = 0; // down
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    72
493
b17c95eac6b2 Added frame counter.
Florian Pose <fp@igh-essen.com>
parents: 398
diff changeset
    73
    device->tx_count = 0;
b17c95eac6b2 Added frame counter.
Florian Pose <fp@igh-essen.com>
parents: 398
diff changeset
    74
    device->rx_count = 0;
b17c95eac6b2 Added frame counter.
Florian Pose <fp@igh-essen.com>
parents: 398
diff changeset
    75
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
    76
#ifdef EC_DBG_IF
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    77
    if (ec_debug_init(&device->dbg)) {
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    78
        EC_ERR("Failed to init debug device!\n");
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    79
        goto out_return;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    80
    }
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
    81
#endif
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    82
211
c684b6b7adaf Using kernel Ethernet constants.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    83
    if (!(device->tx_skb = dev_alloc_skb(ETH_FRAME_LEN))) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
    84
        EC_ERR("Error allocating device socket buffer!\n");
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
    85
#ifdef EC_DBG_IF
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    86
        goto out_debug;
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
    87
#else
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
    88
        goto out_return;
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
    89
#endif
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
    90
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
    91
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    92
    device->tx_skb->dev = net_dev;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    93
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    94
    // add Ethernet-II-header
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    95
    skb_reserve(device->tx_skb, ETH_HLEN);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    96
    eth = (struct ethhdr *) skb_push(device->tx_skb, ETH_HLEN);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    97
    eth->h_proto = htons(0x88A4);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    98
    memcpy(eth->h_source, net_dev->dev_addr, net_dev->addr_len);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    99
    memset(eth->h_dest, 0xFF, net_dev->addr_len);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   100
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   101
    return 0;
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   102
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
   103
#ifdef EC_DBG_IF
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   104
 out_debug:
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   105
    ec_debug_clear(&device->dbg);
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
   106
#endif
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   107
 out_return:
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   108
    return -1;
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   109
}
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   110
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   111
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   114
   EtherCAT device destuctor.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   115
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   116
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   117
void ec_device_clear(ec_device_t *device /**< EtherCAT device */)
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   118
{
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   119
    if (device->open) ec_device_close(device);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   120
    if (device->tx_skb) dev_kfree_skb(device->tx_skb);
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
   121
#ifdef EC_DBG_IF
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   122
    ec_debug_clear(&device->dbg);
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
   123
#endif
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   126
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   129
   Opens the EtherCAT device.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   130
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   131
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   132
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   133
int ec_device_open(ec_device_t *device /**< EtherCAT device */)
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   135
    unsigned int i;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   136
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   137
    if (!device->dev) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
   138
        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
   139
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   140
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   141
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   142
    if (device->open) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
   143
        EC_WARN("Device already opened!\n");
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   144
        return 0;
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   145
    }
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   146
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   147
    // device could have received frames before
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
   148
    for (i = 0; i < 4; i++) ec_device_poll(device);
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   149
96
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   150
    device->link_state = 0;
493
b17c95eac6b2 Added frame counter.
Florian Pose <fp@igh-essen.com>
parents: 398
diff changeset
   151
    device->tx_count = 0;
b17c95eac6b2 Added frame counter.
Florian Pose <fp@igh-essen.com>
parents: 398
diff changeset
   152
    device->rx_count = 0;
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   153
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   154
    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
   155
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   156
    return device->open ? 0 : -1;
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   159
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   162
   Stops the EtherCAT device.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   163
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   164
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   165
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   166
int ec_device_close(ec_device_t *device /**< EtherCAT device */)
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   167
{
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   168
    if (!device->dev) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
   169
        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
   170
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   171
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   172
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   173
    if (!device->open) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
   174
        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
   175
        return 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   176
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   177
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   178
    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
   179
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   180
    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
   181
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   182
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   183
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   184
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   185
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   186
   Returns a pointer to the device's transmit memory.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   187
   \return pointer to the TX socket buffer
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   188
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   189
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   190
uint8_t *ec_device_tx_data(ec_device_t *device /**< EtherCAT device */)
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   191
{
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   192
    return device->tx_skb->data + ETH_HLEN;
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   195
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   198
   Sends the content of the transmit socket buffer.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   199
   Cuts the socket buffer content to the (now known) size, and calls the
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   200
   start_xmit() function of the assigned net_device.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   201
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   202
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   203
void ec_device_send(ec_device_t *device, /**< EtherCAT device */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   204
                    size_t size /**< number of bytes to send */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   205
                    )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   206
{
97
e6264685dd7b Link-Down-Verhalten verbessert.
Florian Pose <fp@igh-essen.com>
parents: 96
diff changeset
   207
    if (unlikely(!device->link_state)) // Link down
96
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   208
        return;
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   209
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   210
    // set the right length for the data
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   211
    device->tx_skb->len = ETH_HLEN + size;
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   212
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   213
    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
   214
        EC_DBG("sending frame:\n");
152
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   215
        ec_print_data(device->tx_skb->data + ETH_HLEN, size);
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   216
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   217
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
   218
#ifdef EC_DBG_IF
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   219
    ec_debug_send(&device->dbg, device->tx_skb->data, ETH_HLEN + size);
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
   220
#endif
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   221
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   222
    // start sending
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   223
    device->dev->hard_start_xmit(device->tx_skb, device->dev);
493
b17c95eac6b2 Added frame counter.
Florian Pose <fp@igh-essen.com>
parents: 398
diff changeset
   224
    device->tx_count++;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   225
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   226
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   227
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   228
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   229
/**
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
   230
   Calls the poll function of the assigned net_device.
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   231
   The master itself works without using interrupts. Therefore the processing
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   232
   of received data and status changes of the network device has to be
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   233
   done by the master calling the ISR "manually".
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   234
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   235
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
   236
void ec_device_poll(ec_device_t *device /**< EtherCAT device */)
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
   237
{
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
   238
    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
   239
    device->jiffies_poll = jiffies;
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
   240
    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
   241
}
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   242
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   243
/******************************************************************************
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   244
 *  Device interface
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   245
 *****************************************************************************/
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   246
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   247
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   248
   Accepts a received frame.
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   249
   Forwards the received data to the master. The master will analyze the frame
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   250
   and dispatch the received commands to the sending instances.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   251
   \ingroup DeviceInterface
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   252
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   253
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   254
void ecdev_receive(ec_device_t *device, /**< EtherCAT device */
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   255
                   const void *data, /**< pointer to received data */
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   256
                   size_t size /**< number of bytes received */
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   257
                   )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   258
{
493
b17c95eac6b2 Added frame counter.
Florian Pose <fp@igh-essen.com>
parents: 398
diff changeset
   259
    device->rx_count++;
b17c95eac6b2 Added frame counter.
Florian Pose <fp@igh-essen.com>
parents: 398
diff changeset
   260
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   261
    if (unlikely(device->master->debug_level > 1)) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
   262
        EC_DBG("Received frame:\n");
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   263
        ec_print_data_diff(device->tx_skb->data + ETH_HLEN,
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   264
                           data + ETH_HLEN, size - ETH_HLEN);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   265
    }
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   266
392
eaee3c8d6ae0 Debug interfaces not compiled by default.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
   267
#ifdef EC_DBG_IF
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   268
    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
   269
#endif
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   270
331
17f58fe99511 Renamed ec_master_receive() to ec_master_receive_datagrams().
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   271
    ec_master_receive_datagrams(device->master,
17f58fe99511 Renamed ec_master_receive() to ec_master_receive_datagrams().
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   272
                                data + ETH_HLEN,
17f58fe99511 Renamed ec_master_receive() to ec_master_receive_datagrams().
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   273
                                size - ETH_HLEN);
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   274
}
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   275
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   276
/*****************************************************************************/
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   277
96
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   278
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   279
   Sets a new link state.
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   280
   If the device notifies the master about the link being down, the master
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   281
   will not try to send frames using this device.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   282
   \ingroup DeviceInterface
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   283
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   284
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   285
void ecdev_link_state(ec_device_t *device, /**< EtherCAT device */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   286
                      uint8_t state /**< new link state */
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   287
                      )
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   288
{
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   289
    if (unlikely(!device)) {
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   290
        EC_WARN("ecdev_link_state: no device!\n");
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   291
        return;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   292
    }
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   293
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   294
    if (likely(state != device->link_state)) {
96
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   295
        device->link_state = state;
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   296
        EC_INFO("Link state changed to %s.\n", (state ? "UP" : "DOWN"));
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   297
    }
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   298
}
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   299
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   300
/*****************************************************************************/
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   301
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   302
/** \cond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   303
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   304
EXPORT_SYMBOL(ecdev_receive);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   305
EXPORT_SYMBOL(ecdev_link_state);
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   306
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   307
/** \endcond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   308
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   309
/*****************************************************************************/