master/master.h
author Florian Pose <fp@igh-essen.com>
Thu, 19 Feb 2015 15:19:29 +0100
changeset 2598 19ff84bbbcb3
parent 2589 2b9c78543663
child 2620 0e4d098db815
permissions -rw-r--r--
Fixed bug concerning netdev_completed_queue(); thanks to B. Benner.
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
 *
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
     5
 *  Copyright (C) 2006-2012  Florian Pose, Ingenieurgemeinschaft IgH
197
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
 *
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
    11
 *  published by the Free Software Foundation.
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
    12
 *
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
    16
 *  Public License for more details.
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
    17
 *
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1312
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    21
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    22
 *  ---
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    23
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    24
 *  The license mentioned above concerns the source code only. Using the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    25
 *  EtherCAT technology and brand is only permitted in compliance with the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1335
diff changeset
    26
 *  industrial property and similar rights of Beckhoff Automation GmbH.
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 241
diff changeset
    27
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    28
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    30
/**
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    31
   \file
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    32
   EtherCAT master structure.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    33
*/
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
/*****************************************************************************/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    36
883
4963e22a267a Equalized defines against duplicated header inclusion.
Florian Pose <fp@igh-essen.com>
parents: 872
diff changeset
    37
#ifndef __EC_MASTER_H__
4963e22a267a Equalized defines against duplicated header inclusion.
Florian Pose <fp@igh-essen.com>
parents: 872
diff changeset
    38
#define __EC_MASTER_H__
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
1250
642048176899 Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents: 1241
diff changeset
    40
#include <linux/version.h>
95
0066de7a456d Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents: 94
diff changeset
    41
#include <linux/list.h>
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    42
#include <linux/timer.h>
601
d6d951b766e3 Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents: 597
diff changeset
    43
#include <linux/wait.h>
1241
794cbccdcd00 Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents: 1200
diff changeset
    44
#include <linux/kthread.h>
1369
61793d845ad6 Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    45
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
    46
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
    47
#include <linux/semaphore.h>
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
    48
#else
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
    49
#include <asm/semaphore.h>
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
    50
#endif
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
    51
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    52
#include "device.h"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    53
#include "domain.h"
1485
5ddc3a455059 ethercat eoe command.
Florian Pose <fp@igh-essen.com>
parents: 1436
diff changeset
    54
#include "ethernet.h"
528
f789bdd78b54 Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents: 525
diff changeset
    55
#include "fsm_master.h"
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents: 900
diff changeset
    56
#include "cdev.h"
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
    58
#ifdef EC_RTDM
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
    59
#include "rtdm.h"
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
    60
#endif
2028
55854f070c4a use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents: 2024
diff changeset
    61
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    62
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    64
/** Convenience macro for printing master-specific information to syslog.
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    65
 *
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    66
 * This will print the message in \a fmt with a prefixed "EtherCAT <INDEX>: ",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    67
 * where INDEX is the master index.
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    68
 *
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    69
 * \param master EtherCAT master
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    70
 * \param fmt format string (like in printf())
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    71
 * \param args arguments (optional)
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    72
 */
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    73
#define EC_MASTER_INFO(master, fmt, args...) \
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    74
    printk(KERN_INFO "EtherCAT %u: " fmt, master->index, ##args)
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    75
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    76
/** Convenience macro for printing master-specific errors to syslog.
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    77
 *
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    78
 * This will print the message in \a fmt with a prefixed "EtherCAT <INDEX>: ",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    79
 * where INDEX is the master index.
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    80
 *
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    81
 * \param master EtherCAT master
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    82
 * \param fmt format string (like in printf())
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    83
 * \param args arguments (optional)
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    84
 */
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    85
#define EC_MASTER_ERR(master, fmt, args...) \
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    86
    printk(KERN_ERR "EtherCAT ERROR %u: " fmt, master->index, ##args)
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    87
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    88
/** Convenience macro for printing master-specific warnings to syslog.
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    89
 *
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    90
 * This will print the message in \a fmt with a prefixed "EtherCAT <INDEX>: ",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    91
 * where INDEX is the master index.
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    92
 *
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    93
 * \param master EtherCAT master
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    94
 * \param fmt format string (like in printf())
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    95
 * \param args arguments (optional)
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    96
 */
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    97
#define EC_MASTER_WARN(master, fmt, args...) \
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    98
    printk(KERN_WARNING "EtherCAT WARNING %u: " fmt, master->index, ##args)
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
    99
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   100
/** Convenience macro for printing master-specific debug messages to syslog.
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   101
 *
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   102
 * This will print the message in \a fmt with a prefixed "EtherCAT <INDEX>: ",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   103
 * where INDEX is the master index.
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   104
 *
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   105
 * \param master EtherCAT master
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   106
 * \param level Debug level. Master's debug level must be >= \a level for
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   107
 * output.
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   108
 * \param fmt format string (like in printf())
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   109
 * \param args arguments (optional)
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   110
 */
2037
ea0319750e13 Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents: 2028
diff changeset
   111
#define EC_MASTER_DBG(master, level, fmt, args...) \
ea0319750e13 Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents: 2028
diff changeset
   112
    do { \
ea0319750e13 Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents: 2028
diff changeset
   113
        if (master->debug_level >= level) { \
ea0319750e13 Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents: 2028
diff changeset
   114
            printk(KERN_DEBUG "EtherCAT DEBUG %u: " fmt, \
ea0319750e13 Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents: 2028
diff changeset
   115
                    master->index, ##args); \
ea0319750e13 Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents: 2028
diff changeset
   116
        } \
ea0319750e13 Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents: 2028
diff changeset
   117
    } while (0)
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   118
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   119
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   120
/** Size of the external datagram ring.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   121
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   122
 * The external datagram ring is used for slave FSMs.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   123
 */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   124
#define EC_EXT_RING_SIZE 32
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   125
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   126
/*****************************************************************************/
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   127
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   128
/** EtherCAT master phase.
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   129
 */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   130
typedef enum {
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   131
    EC_ORPHANED, /**< Orphaned phase. The master has no Ethernet device
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   132
                   attached. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   133
    EC_IDLE, /**< Idle phase. An Ethernet device is attached, but the master
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   134
               is not in use, yet. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   135
    EC_OPERATION /**< Operation phase. The master was requested by a realtime
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   136
                   application. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   137
} ec_master_phase_t;
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   138
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   139
/*****************************************************************************/
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   140
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   141
/** Cyclic statistics.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   142
 */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   143
typedef struct {
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 286
diff changeset
   144
    unsigned int timeouts; /**< datagram timeouts */
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   145
    unsigned int corrupted; /**< corrupted frames */
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
   146
    unsigned int unmatched; /**< unmatched datagrams (received, but not
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 331
diff changeset
   147
                               queued any longer) */
344
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 335
diff changeset
   148
    unsigned long output_jiffies; /**< time of last output */
849
4b712ec8929d Removed slave pointer from ec_sdo_request_t class.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   149
} ec_stats_t;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   150
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   151
/*****************************************************************************/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   152
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   153
/** Device statistics.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   154
 */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   155
typedef struct {
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   156
    u64 tx_count; /**< Number of frames sent. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   157
    u64 last_tx_count; /**< Number of frames sent of last statistics cycle. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   158
    u64 rx_count; /**< Number of frames received. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   159
    u64 last_rx_count; /**< Number of frames received of last statistics
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   160
                         cycle. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   161
    u64 tx_bytes; /**< Number of bytes sent. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   162
    u64 last_tx_bytes; /**< Number of bytes sent of last statistics cycle. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   163
    u64 rx_bytes; /**< Number of bytes received. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   164
    u64 last_rx_bytes; /**< Number of bytes received of last statistics cycle.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   165
                        */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   166
    u64 last_loss; /**< Tx/Rx difference of last statistics cycle. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   167
    s32 tx_frame_rates[EC_RATE_COUNT]; /**< Transmit rates in frames/s for
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   168
                                         different statistics cycle periods.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   169
                                        */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   170
    s32 rx_frame_rates[EC_RATE_COUNT]; /**< Receive rates in frames/s for
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   171
                                         different statistics cycle periods.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   172
                                        */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   173
    s32 tx_byte_rates[EC_RATE_COUNT]; /**< Transmit rates in byte/s for
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   174
                                        different statistics cycle periods. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   175
    s32 rx_byte_rates[EC_RATE_COUNT]; /**< Receive rates in byte/s for
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   176
                                        different statistics cycle periods. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   177
    s32 loss_rates[EC_RATE_COUNT]; /**< Frame loss rates for different
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   178
                                     statistics cycle periods. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   179
    unsigned long jiffies; /**< Jiffies of last statistic cycle. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   180
} ec_device_stats_t;
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   181
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   182
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   183
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   184
#if EC_MAX_NUM_DEVICES < 1
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   185
#error Invalid number of devices
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   186
#endif
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   187
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   188
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   189
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   190
/** EtherCAT master.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   191
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   192
 * Manages slaves, domains and IO.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   193
 */
849
4b712ec8929d Removed slave pointer from ec_sdo_request_t class.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   194
struct ec_master {
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   195
    unsigned int index; /**< Index. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   196
    unsigned int reserved; /**< \a True, if the master is in use. */
241
cd90a22cab28 Minor changes in master.h
Florian Pose <fp@igh-essen.com>
parents: 239
diff changeset
   197
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents: 900
diff changeset
   198
    ec_cdev_t cdev; /**< Master character device. */
1250
642048176899 Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents: 1241
diff changeset
   199
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
642048176899 Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents: 1241
diff changeset
   200
    struct device *class_device; /**< Master class device. */
642048176899 Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents: 1241
diff changeset
   201
#else
1013
52256b75f975 Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents: 1000
diff changeset
   202
    struct class_device *class_device; /**< Master class device. */
1250
642048176899 Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents: 1241
diff changeset
   203
#endif
642048176899 Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents: 1241
diff changeset
   204
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   205
#ifdef EC_RTDM
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   206
    ec_rtdm_dev_t rtdm_dev; /**< RTDM device. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   207
#endif
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   208
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   209
    struct semaphore master_sem; /**< Master semaphore. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   210
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   211
    ec_device_t devices[EC_MAX_NUM_DEVICES]; /**< EtherCAT devices. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   212
    const uint8_t *macs[EC_MAX_NUM_DEVICES]; /**< Device MAC addresses. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   213
#if EC_MAX_NUM_DEVICES > 1
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   214
    unsigned int num_devices; /**< Number of devices. Access this always via
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   215
                                ec_master_num_devices(), because it may be
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   216
                                optimized! */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   217
#endif
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   218
    struct semaphore device_sem; /**< Device semaphore. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   219
    ec_device_stats_t device_stats; /**< Device statistics. */
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   220
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   221
    ec_fsm_master_t fsm; /**< Master state machine. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   222
    ec_datagram_t fsm_datagram; /**< Datagram used for state machines. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   223
    ec_master_phase_t phase; /**< Master phase. */
1530
96629de2202b Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents: 1516
diff changeset
   224
    unsigned int active; /**< Master has been activated. */
1925
29161abef052 Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents: 1921
diff changeset
   225
    unsigned int config_changed; /**< The configuration changed. */
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   226
    unsigned int injection_seq_fsm; /**< Datagram injection sequence number
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   227
                                      for the FSM side. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   228
    unsigned int injection_seq_rt; /**< Datagram injection sequence number
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   229
                                     for the realtime side. */
334
2be97e069602 Master information, timing.
Florian Pose <fp@igh-essen.com>
parents: 332
diff changeset
   230
1000
5746fdd1ca2e Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents: 997
diff changeset
   231
    ec_slave_t *slaves; /**< Array of slaves on the bus. */
5746fdd1ca2e Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents: 997
diff changeset
   232
    unsigned int slave_count; /**< Number of slaves on the bus. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   233
1939
1ba48f78a0a5 Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents: 1930
diff changeset
   234
    /* Configuration applied by the application. */
1028
afdd4bdbb7ec Removed configs_attached flag; changed return value of
Florian Pose <fp@igh-essen.com>
parents: 1013
diff changeset
   235
    struct list_head configs; /**< List of slave configurations. */
1939
1ba48f78a0a5 Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents: 1930
diff changeset
   236
    struct list_head domains; /**< List of domains. */
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   237
1396
9d04cc08f40f DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1394
diff changeset
   238
    u64 app_time; /**< Time of the last ecrt_master_sync() call. */
1436
08eaf72409bb Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents: 1425
diff changeset
   239
    u64 app_start_time; /**< Application start time. */
1925
29161abef052 Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents: 1921
diff changeset
   240
    u8 has_app_time; /**< Application time is valid. */
1396
9d04cc08f40f DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1394
diff changeset
   241
    ec_datagram_t ref_sync_datagram; /**< Datagram used for synchronizing the
9d04cc08f40f DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1394
diff changeset
   242
                                       reference clock to the master clock. */
1394
e77728ddf0f9 Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents: 1388
diff changeset
   243
    ec_datagram_t sync_datagram; /**< Datagram used for DC drift
e77728ddf0f9 Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents: 1388
diff changeset
   244
                                   compensation. */
1535
0c484ee12d89 DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents: 1530
diff changeset
   245
    ec_datagram_t sync_mon_datagram; /**< Datagram used for DC synchronisation
0c484ee12d89 DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents: 1530
diff changeset
   246
                                       monitoring. */
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   247
    ec_slave_config_t *dc_ref_config; /**< Application-selected DC reference
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   248
                                        clock slave config. */
1425
c1322a8793c0 Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1421
diff changeset
   249
    ec_slave_t *dc_ref_clock; /**< DC reference clock slave. */
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   250
900
f8b5c6d21705 Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents: 883
diff changeset
   251
    unsigned int scan_busy; /**< Current scan state. */
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   252
    unsigned int allow_scan; /**< \a True, if slave scanning is allowed. */
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   253
    struct semaphore scan_sem; /**< Semaphore protecting the \a scan_busy
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   254
                                 variable and the \a allow_scan flag. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   255
    wait_queue_head_t scan_queue; /**< Queue for processes that wait for
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   256
                                    slave scanning. */
656
370aa8c2d1b1 Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents: 647
diff changeset
   257
900
f8b5c6d21705 Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents: 883
diff changeset
   258
    unsigned int config_busy; /**< State of slave configuration. */
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   259
    struct semaphore config_sem; /**< Semaphore protecting the \a config_busy
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   260
                                   variable and the allow_config flag. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   261
    wait_queue_head_t config_queue; /**< Queue for processes that wait for
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   262
                                      slave configuration. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   263
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   264
    struct list_head datagram_queue; /**< Datagram queue. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   265
    uint8_t datagram_index; /**< Current datagram index. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   266
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   267
    struct list_head ext_datagram_queue; /**< Queue for non-application
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   268
                                           datagrams. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   269
    struct semaphore ext_queue_sem; /**< Semaphore protecting the \a
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   270
                                      ext_datagram_queue. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   271
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   272
    ec_datagram_t ext_datagram_ring[EC_EXT_RING_SIZE]; /**< External datagram
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   273
                                                         ring. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   274
    unsigned int ext_ring_idx_rt; /**< Index in external datagram ring for RT
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   275
                                    side. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   276
    unsigned int ext_ring_idx_fsm; /**< Index in external datagram ring for
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   277
                                     FSM side. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   278
    unsigned int send_interval; /**< Interval between two calls to
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   279
                                  ecrt_master_send(). */
1907
dd276ae226b4 Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents: 1848
diff changeset
   280
    size_t max_queue_size; /**< Maximum size of datagram queue */
241
cd90a22cab28 Minor changes in master.h
Florian Pose <fp@igh-essen.com>
parents: 239
diff changeset
   281
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   282
    ec_slave_t *fsm_slave; /**< Slave that is queried next for FSM exec. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   283
    struct list_head fsm_exec_list; /**< Slave FSM execution list. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   284
    unsigned int fsm_exec_count; /**< Number of entries in execution list. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   285
1399
f79d4bb5b23a Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents: 1396
diff changeset
   286
    unsigned int debug_level; /**< Master debug level. */
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   287
    ec_stats_t stats; /**< Cyclic statistics. */
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   288
1241
794cbccdcd00 Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents: 1200
diff changeset
   289
    struct task_struct *thread; /**< Master thread. */
241
cd90a22cab28 Minor changes in master.h
Florian Pose <fp@igh-essen.com>
parents: 239
diff changeset
   290
715
f12ff7c08623 Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents: 664
diff changeset
   291
#ifdef EC_EOE
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   292
    struct task_struct *eoe_thread; /**< EoE thread. */
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   293
    struct list_head eoe_handlers; /**< Ethernet over EtherCAT handlers. */
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   294
#endif
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   295
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   296
    struct semaphore io_sem; /**< Semaphore used in \a IDLE phase. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   297
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   298
    void (*send_cb)(void *); /**< Current send datagrams callback. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   299
    void (*receive_cb)(void *); /**< Current receive datagrams callback. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   300
    void *cb_data; /**< Current callback data. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   301
    void (*app_send_cb)(void *); /**< Application's send datagrams
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   302
                                          callback. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   303
    void (*app_receive_cb)(void *); /**< Application's receive datagrams
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   304
                                      callback. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   305
    void *app_cb_data; /**< Application callback data. */
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   306
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   307
    struct list_head sii_requests; /**< SII write requests. */
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   308
    struct list_head emerg_reg_requests; /**< Emergency register access
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   309
                                           requests. */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   310
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   311
    wait_queue_head_t request_queue; /**< Wait queue for external requests
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   312
                                       from user space. */
55
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
   313
};
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   315
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
1279
6911450535b7 merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents: 1252
diff changeset
   317
// static funtions
6911450535b7 merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents: 1252
diff changeset
   318
void ec_master_init_static(void);
6911450535b7 merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents: 1252
diff changeset
   319
448
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
   320
// master creation/deletion
997
652180478e95 Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents: 992
diff changeset
   321
int ec_master_init(ec_master_t *, unsigned int, const uint8_t *,
1399
f79d4bb5b23a Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents: 1396
diff changeset
   322
        const uint8_t *, dev_t, struct class *, unsigned int);
639
aa23c48dca2d Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents: 637
diff changeset
   323
void ec_master_clear(ec_master_t *);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   324
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   325
/** Number of Ethernet devices.
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   326
 */
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   327
#if EC_MAX_NUM_DEVICES > 1
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   328
#define ec_master_num_devices(MASTER) ((MASTER)->num_devices)
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   329
#else
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   330
#define ec_master_num_devices(MASTER) 1
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   331
#endif
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   332
1029
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   333
// phase transitions
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   334
int ec_master_enter_idle_phase(ec_master_t *);
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   335
void ec_master_leave_idle_phase(ec_master_t *);
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   336
int ec_master_enter_operation_phase(ec_master_t *);
61ffe5f22306 Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents: 1028
diff changeset
   337
void ec_master_leave_operation_phase(ec_master_t *);
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   338
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   339
#ifdef EC_EOE
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   340
// EoE
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   341
void ec_master_eoe_start(ec_master_t *);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   342
void ec_master_eoe_stop(ec_master_t *);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   343
#endif
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   344
446
8fede404c01f Persistent slave lists.
Florian Pose <fp@igh-essen.com>
parents: 441
diff changeset
   345
// datagram IO
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   346
void ec_master_receive_datagrams(ec_master_t *, ec_device_t *,
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   347
        const uint8_t *, size_t);
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 286
diff changeset
   348
void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *);
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   349
void ec_master_queue_datagram_ext(ec_master_t *, ec_datagram_t *);
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   351
// misc.
1930
59a50053ccc6 Made send_interval variable an unsigned int; fixed format specifiers for
Florian Pose <fp@igh-essen.com>
parents: 1925
diff changeset
   352
void ec_master_set_send_interval(ec_master_t *, unsigned int);
1028
afdd4bdbb7ec Removed configs_attached flag; changed return value of
Florian Pose <fp@igh-essen.com>
parents: 1013
diff changeset
   353
void ec_master_attach_slave_configs(ec_master_t *);
927
ffb7d1876ce0 Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   354
ec_slave_t *ec_master_find_slave(ec_master_t *, uint16_t, uint16_t);
1077
c95cd717b852 Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   355
const ec_slave_t *ec_master_find_slave_const(const ec_master_t *, uint16_t,
c95cd717b852 Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   356
        uint16_t);
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 306
diff changeset
   357
void ec_master_output_stats(ec_master_t *);
715
f12ff7c08623 Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents: 664
diff changeset
   358
#ifdef EC_EOE
661
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 656
diff changeset
   359
void ec_master_clear_eoe_handlers(ec_master_t *);
715
f12ff7c08623 Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents: 664
diff changeset
   360
#endif
992
50a44cbd30af Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents: 990
diff changeset
   361
void ec_master_clear_slaves(ec_master_t *);
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 306
diff changeset
   362
990
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 956
diff changeset
   363
unsigned int ec_master_config_count(const ec_master_t *);
1252
0b411da5fd24 Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents: 1250
diff changeset
   364
ec_slave_config_t *ec_master_get_config(
0b411da5fd24 Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents: 1250
diff changeset
   365
        const ec_master_t *, unsigned int);
990
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 956
diff changeset
   366
const ec_slave_config_t *ec_master_get_config_const(
4f223f3df05a Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents: 956
diff changeset
   367
        const ec_master_t *, unsigned int);
946
6ef20c5de875 Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents: 927
diff changeset
   368
unsigned int ec_master_domain_count(const ec_master_t *);
6ef20c5de875 Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents: 927
diff changeset
   369
ec_domain_t *ec_master_find_domain(ec_master_t *, unsigned int);
1078
fce58ba8a912 Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents: 1077
diff changeset
   370
const ec_domain_t *ec_master_find_domain_const(const ec_master_t *,
fce58ba8a912 Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents: 1077
diff changeset
   371
        unsigned int);
1516
e3b09f847512 Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents: 1513
diff changeset
   372
#ifdef EC_EOE
1485
5ddc3a455059 ethercat eoe command.
Florian Pose <fp@igh-essen.com>
parents: 1436
diff changeset
   373
uint16_t ec_master_eoe_handler_count(const ec_master_t *);
5ddc3a455059 ethercat eoe command.
Florian Pose <fp@igh-essen.com>
parents: 1436
diff changeset
   374
const ec_eoe_t *ec_master_get_eoe_handler_const(const ec_master_t *, uint16_t);
1516
e3b09f847512 Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents: 1513
diff changeset
   375
#endif
946
6ef20c5de875 Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents: 927
diff changeset
   376
1399
f79d4bb5b23a Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents: 1396
diff changeset
   377
int ec_master_debug_level(ec_master_t *, unsigned int);
956
d9b9bc794d10 Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents: 946
diff changeset
   378
1312
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1279
diff changeset
   379
ec_domain_t *ecrt_master_create_domain_err(ec_master_t *);
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1279
diff changeset
   380
ec_slave_config_t *ecrt_master_slave_config_err(ec_master_t *, uint16_t,
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1279
diff changeset
   381
        uint16_t, uint32_t, uint32_t);
74853e018898 Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents: 1279
diff changeset
   382
1425
c1322a8793c0 Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1421
diff changeset
   383
void ec_master_calc_dc(ec_master_t *);
1925
29161abef052 Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents: 1921
diff changeset
   384
void ec_master_request_op(ec_master_t *);
1425
c1322a8793c0 Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents: 1421
diff changeset
   385
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   386
void ec_master_internal_send_cb(void *);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   387
void ec_master_internal_receive_cb(void *);
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   388
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   389
extern const unsigned int rate_intervals[EC_RATE_COUNT]; // see master.c
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   390
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   391
/*****************************************************************************/
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   392
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2117
diff changeset
   393
#endif