master/ethernet.c
author Florian Pose <fp@igh-essen.com>
Fri, 03 Mar 2017 16:49:13 +0100
changeset 2677 9b88313c4e58
parent 2650 0dc0873d4aed
permissions -rw-r--r--
Optionally output CRC diagnosis information in graph.
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
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: 1313
diff changeset
     5
 *  Copyright (C) 2006-2008  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: 1313
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: 1313
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: 1313
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: 1313
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: 1313
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: 1313
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: 1313
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: 1313
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: 1313
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: 1313
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: 1313
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: 1340
diff changeset
    22
 *  ---
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1340
diff changeset
    23
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1340
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: 1340
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: 1340
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: 235
diff changeset
    27
 *
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *****************************************************************************/
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
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
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    32
   Ethernet over EtherCAT (EoE).
199
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
1579
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
    37
#include <linux/version.h>
294
feea8d850c65 Applied include patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents: 293
diff changeset
    38
#include <linux/netdevice.h>
210
1cc6bcb1e6ae EoE frame receiving; regarding open/stop commands.
Florian Pose <fp@igh-essen.com>
parents: 208
diff changeset
    39
#include <linux/etherdevice.h>
1cc6bcb1e6ae EoE frame receiving; regarding open/stop commands.
Florian Pose <fp@igh-essen.com>
parents: 208
diff changeset
    40
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include "globals.h"
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include "master.h"
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include "slave.h"
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include "mailbox.h"
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include "ethernet.h"
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
629
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 610
diff changeset
    47
/*****************************************************************************/
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 610
diff changeset
    48
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
    49
/** Defines the debug level of EoE processing.
629
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 610
diff changeset
    50
 *
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 610
diff changeset
    51
 * 0 = No debug messages.
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
    52
 * 1 = Output warnings.
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
    53
 * 2 = Output actions.
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
    54
 * 3 = Output actions and frame data.
629
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 610
diff changeset
    55
 */
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
    56
#define EOE_DEBUG_LEVEL 1
215
b021aa6eee38 EoE: TCP traffic possible; TX fragmenting to do.
Florian Pose <fp@igh-essen.com>
parents: 214
diff changeset
    57
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
    58
/** Size of the EoE tx queue.
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
    59
 */
629
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 610
diff changeset
    60
#define EC_EOE_TX_QUEUE_SIZE 100
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 610
diff changeset
    61
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
    62
/** Number of tries.
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
    63
 */
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
    64
#define EC_EOE_TRIES 100
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
    65
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
/*****************************************************************************/
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
    68
void ec_eoe_flush(ec_eoe_t *);
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
    69
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
    70
// state functions
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
    71
void ec_eoe_state_rx_start(ec_eoe_t *);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
    72
void ec_eoe_state_rx_check(ec_eoe_t *);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
    73
void ec_eoe_state_rx_fetch(ec_eoe_t *);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
    74
void ec_eoe_state_tx_start(ec_eoe_t *);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
    75
void ec_eoe_state_tx_sent(ec_eoe_t *);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
    76
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
    77
// net_device functions
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    78
int ec_eoedev_open(struct net_device *);
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    79
int ec_eoedev_stop(struct net_device *);
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    80
int ec_eoedev_tx(struct sk_buff *, struct net_device *);
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    81
struct net_device_stats *ec_eoedev_stats(struct net_device *);
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
    82
static int ec_eoedev_set_mac(struct net_device *netdev, void *p);
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    83
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    84
/*****************************************************************************/
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    85
1561
89f6cd5b90ff Use net_device_ops also for EoE devices from 2.6.29 on.
Florian Pose <fp@igh-essen.com>
parents: 1552
diff changeset
    86
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
1907
dd276ae226b4 Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents: 1581
diff changeset
    87
/** Device operations for EoE interfaces.
dd276ae226b4 Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents: 1581
diff changeset
    88
 */
1561
89f6cd5b90ff Use net_device_ops also for EoE devices from 2.6.29 on.
Florian Pose <fp@igh-essen.com>
parents: 1552
diff changeset
    89
static const struct net_device_ops ec_eoedev_ops = {
1579
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
    90
    .ndo_open = ec_eoedev_open,
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
    91
    .ndo_stop = ec_eoedev_stop,
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
    92
    .ndo_start_xmit = ec_eoedev_tx,
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
    93
    .ndo_get_stats = ec_eoedev_stats,
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
    94
    .ndo_set_mac_address = ec_eoedev_set_mac,
1579
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
    95
};
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
    96
#endif
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
    97
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    98
/*****************************************************************************/
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    99
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   100
/**
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   101
 * ec_eoedev_set_mac - Change the Ethernet Address of the NIC
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   102
 * @netdev: network interface device structure
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   103
 * @p: pointer to an address structure
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   104
 *
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   105
 * Returns 0 on success, negative on failure
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   106
 **/
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   107
static int
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   108
ec_eoedev_set_mac(struct net_device *netdev, void *p)
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   109
{
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   110
   struct sockaddr *addr = p;
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   111
2650
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   112
   if (!is_valid_ether_addr(addr->sa_data)) {
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   113
      return -EADDRNOTAVAIL;
2650
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   114
   }
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   115
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   116
   memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   117
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   118
   return 0;
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   119
}
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   120
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   121
/*****************************************************************************/
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   122
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   123
/** EoE constructor.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   124
 *
661
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   125
 * Initializes the EoE handler, creates a net_device and registers it.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   126
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   127
 * \return Zero on success, otherwise a negative error code.
661
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   128
 */
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   129
int ec_eoe_init(
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   130
        ec_eoe_t *eoe, /**< EoE handler */
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   131
        ec_slave_t *slave /**< EtherCAT slave */
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   132
        )
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   133
{
213
8d723b9833a9 removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents: 212
diff changeset
   134
    ec_eoe_t **priv;
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   135
    int ret = 0;
719
03d5b96632fb Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents: 712
diff changeset
   136
    char name[EC_DATAGRAM_NAME_SIZE];
661
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   137
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   138
    struct net_device *dev;
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   139
    unsigned char lo_mac[ETH_ALEN] = {0};
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   140
    unsigned int use_master_mac = 0;
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   141
661
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   142
    eoe->slave = slave;
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   143
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   144
    ec_datagram_init(&eoe->datagram);
721
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   145
    eoe->queue_datagram = 0;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   146
    eoe->state = ec_eoe_state_rx_start;
210
1cc6bcb1e6ae EoE frame receiving; regarding open/stop commands.
Florian Pose <fp@igh-essen.com>
parents: 208
diff changeset
   147
    eoe->opened = 0;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   148
    eoe->rx_skb = NULL;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   149
    eoe->rx_expected_fragment = 0;
212
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   150
    INIT_LIST_HEAD(&eoe->tx_queue);
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   151
    eoe->tx_frame = NULL;
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   152
    eoe->tx_queue_active = 0;
1485
5ddc3a455059 ethercat eoe command.
Florian Pose <fp@igh-essen.com>
parents: 1484
diff changeset
   153
    eoe->tx_queue_size = EC_EOE_TX_QUEUE_SIZE;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   154
    eoe->tx_queued_frames = 0;
1579
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
   155
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   156
    sema_init(&eoe->tx_queue_sem, 1);
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   157
    eoe->tx_frame_number = 0xFF;
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   158
    memset(&eoe->stats, 0, sizeof(struct net_device_stats));
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   159
336
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   160
    eoe->rx_counter = 0;
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   161
    eoe->tx_counter = 0;
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   162
    eoe->rx_rate = 0;
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   163
    eoe->tx_rate = 0;
344
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 340
diff changeset
   164
    eoe->rate_jiffies = 0;
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   165
    eoe->rx_idle = 1;
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   166
    eoe->tx_idle = 1;
336
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   167
712
14f899ac51f0 Create network interfaces for EoE devices with alias as eoeXaY.
Florian Pose <fp@igh-essen.com>
parents: 689
diff changeset
   168
    /* device name eoe<MASTER>[as]<SLAVE>, because networking scripts don't
14f899ac51f0 Create network interfaces for EoE devices with alias as eoeXaY.
Florian Pose <fp@igh-essen.com>
parents: 689
diff changeset
   169
     * like hyphens etc. in interface names. */
1909
ea3eb4c74c1b Introduced effective_alias variable to separate reg12 alias from SII alias.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   170
    if (slave->effective_alias) {
719
03d5b96632fb Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents: 712
diff changeset
   171
        snprintf(name, EC_DATAGRAM_NAME_SIZE,
1909
ea3eb4c74c1b Introduced effective_alias variable to separate reg12 alias from SII alias.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   172
                "eoe%ua%u", slave->master->index, slave->effective_alias);
712
14f899ac51f0 Create network interfaces for EoE devices with alias as eoeXaY.
Florian Pose <fp@igh-essen.com>
parents: 689
diff changeset
   173
    } else {
719
03d5b96632fb Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents: 712
diff changeset
   174
        snprintf(name, EC_DATAGRAM_NAME_SIZE,
03d5b96632fb Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents: 712
diff changeset
   175
                "eoe%us%u", slave->master->index, slave->ring_position);
03d5b96632fb Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents: 712
diff changeset
   176
    }
03d5b96632fb Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents: 712
diff changeset
   177
03d5b96632fb Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents: 712
diff changeset
   178
    snprintf(eoe->datagram.name, EC_DATAGRAM_NAME_SIZE, name);
661
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   179
2641
535465bf176d New alloc_netdev() API since kernel 3.17.
Florian Pose <fp@igh-essen.com>
parents: 2626
diff changeset
   180
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
535465bf176d New alloc_netdev() API since kernel 3.17.
Florian Pose <fp@igh-essen.com>
parents: 2626
diff changeset
   181
    eoe->dev = alloc_netdev(sizeof(ec_eoe_t *), name, NET_NAME_UNKNOWN,
535465bf176d New alloc_netdev() API since kernel 3.17.
Florian Pose <fp@igh-essen.com>
parents: 2626
diff changeset
   182
            ether_setup);
535465bf176d New alloc_netdev() API since kernel 3.17.
Florian Pose <fp@igh-essen.com>
parents: 2626
diff changeset
   183
#else
535465bf176d New alloc_netdev() API since kernel 3.17.
Florian Pose <fp@igh-essen.com>
parents: 2626
diff changeset
   184
    eoe->dev = alloc_netdev(sizeof(ec_eoe_t *), name, ether_setup);
535465bf176d New alloc_netdev() API since kernel 3.17.
Florian Pose <fp@igh-essen.com>
parents: 2626
diff changeset
   185
#endif
535465bf176d New alloc_netdev() API since kernel 3.17.
Florian Pose <fp@igh-essen.com>
parents: 2626
diff changeset
   186
    if (!eoe->dev) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   187
        EC_SLAVE_ERR(slave, "Unable to allocate net_device %s"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   188
                " for EoE handler!\n", name);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1209
diff changeset
   189
        ret = -ENODEV;
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   190
        goto out_return;
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   191
    }
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   192
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   193
    // initialize net_device
1561
89f6cd5b90ff Use net_device_ops also for EoE devices from 2.6.29 on.
Florian Pose <fp@igh-essen.com>
parents: 1552
diff changeset
   194
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
89f6cd5b90ff Use net_device_ops also for EoE devices from 2.6.29 on.
Florian Pose <fp@igh-essen.com>
parents: 1552
diff changeset
   195
    eoe->dev->netdev_ops = &ec_eoedev_ops;
1579
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
   196
#else
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   197
    eoe->dev->open = ec_eoedev_open;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   198
    eoe->dev->stop = ec_eoedev_stop;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   199
    eoe->dev->hard_start_xmit = ec_eoedev_tx;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   200
    eoe->dev->get_stats = ec_eoedev_stats;
1579
326d47aa986c applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents: 1500
diff changeset
   201
#endif
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   202
2626
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   203
    // First check if the MAC address assigned to the master is globally
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   204
    // unique
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   205
    if ((slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[0] & 0x02) !=
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   206
            0x02) {
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   207
        // The master MAC is unique and the NIC part can be used for the EoE
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   208
        // interface MAC
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   209
        use_master_mac = 1;
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   210
    }
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   211
    else {
2626
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   212
        // The master MAC is not unique, so we check for unique MAC in other
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   213
        // interfaces
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   214
        dev = first_net_device(&init_net);
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   215
        while (dev) {
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   216
            // Check if globally unique MAC address
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   217
            if (dev->addr_len == ETH_ALEN) {
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   218
                if (memcmp(dev->dev_addr, lo_mac, ETH_ALEN) != 0) {
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   219
                    if ((dev->dev_addr[0] & 0x02) != 0x02) {
2626
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   220
                        // The first globally unique MAC address has been
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   221
                        // identified
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   222
                        break;
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   223
                    }
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   224
                }
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   225
            }
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   226
            dev = next_net_device(dev);
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   227
        }
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   228
        if (eoe->dev->addr_len == ETH_ALEN) {
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   229
            if (dev) {
2626
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   230
                // A unique MAC were identified in one of the other network
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   231
                // interfaces and the NIC part can be used for the EoE
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   232
                // interface MAC.
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   233
                EC_SLAVE_INFO(slave, "%s MAC address derived from"
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   234
                        " NIC part of %s MAC address",
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   235
                    eoe->dev->name, dev->name);
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   236
                eoe->dev->dev_addr[1] = dev->dev_addr[3];
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   237
                eoe->dev->dev_addr[2] = dev->dev_addr[4];
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   238
                eoe->dev->dev_addr[3] = dev->dev_addr[5];
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   239
            }
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   240
            else {
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   241
                use_master_mac = 1;
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   242
            }
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   243
        }
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   244
    }
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   245
    if (eoe->dev->addr_len == ETH_ALEN) {
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   246
        if (use_master_mac) {
2626
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   247
            EC_SLAVE_INFO(slave, "%s MAC address derived"
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   248
                    " from NIC part of %s MAC address",
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   249
                eoe->dev->name,
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   250
                slave->master->devices[EC_DEVICE_MAIN].dev->name);
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   251
            eoe->dev->dev_addr[1] =
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   252
                slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[3];
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   253
            eoe->dev->dev_addr[2] =
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   254
                slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[4];
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   255
            eoe->dev->dev_addr[3] =
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   256
                slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[5];
2625
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   257
        }
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   258
        eoe->dev->dev_addr[0] = 0x02;
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   259
        eoe->dev->dev_addr[4] = (uint8_t)(slave->ring_position >> 8);
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   260
        eoe->dev->dev_addr[5] = (uint8_t)(slave->ring_position);
e25af8bd3957 Eoe mac address now derived from unique mac.
Knud Baastrup <kba@deif.com>
parents: 2593
diff changeset
   261
    }
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   262
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   263
    // initialize private data
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   264
    priv = netdev_priv(eoe->dev);
213
8d723b9833a9 removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents: 212
diff changeset
   265
    *priv = eoe;
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   266
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   267
    // Usually setting the MTU appropriately makes the upper layers
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   268
    // do the frame fragmenting. In some cases this doesn't work
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   269
    // so the MTU is left on the Ethernet standard value and fragmenting
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   270
    // is done "manually".
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   271
#if 0
1338
eb31b5a135da merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents: 1337
diff changeset
   272
    eoe->dev->mtu = slave->configured_rx_mailbox_size - ETH_HLEN - 10;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   273
#endif
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   274
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   275
    // connect the net_device to the kernel
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1209
diff changeset
   276
    ret = register_netdev(eoe->dev);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1209
diff changeset
   277
    if (ret) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   278
        EC_SLAVE_ERR(slave, "Unable to register net_device:"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   279
                " error %i\n", ret);
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   280
        goto out_free;
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   281
    }
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   282
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   283
    return 0;
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   284
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   285
 out_free:
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   286
    free_netdev(eoe->dev);
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   287
    eoe->dev = NULL;
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   288
 out_return:
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1209
diff changeset
   289
    return ret;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
}
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
/*****************************************************************************/
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   294
/** EoE destructor.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   295
 *
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   296
 * Unregisteres the net_device and frees allocated memory.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   297
 */
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   298
void ec_eoe_clear(ec_eoe_t *eoe /**< EoE handler */)
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
{
552
029546740810 Minor: Removed warning when EoE interface is up upon master unloading.
Florian Pose <fp@igh-essen.com>
parents: 460
diff changeset
   300
    unregister_netdev(eoe->dev); // possibly calls close callback
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   301
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   302
    // empty transmit queue
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   303
    ec_eoe_flush(eoe);
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   304
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   305
    if (eoe->tx_frame) {
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   306
        dev_kfree_skb(eoe->tx_frame->skb);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   307
        kfree(eoe->tx_frame);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   308
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   309
1552
c9e2c3be294e Later freeing of netdev.
Florian Pose <fp@igh-essen.com>
parents: 1500
diff changeset
   310
    if (eoe->rx_skb)
c9e2c3be294e Later freeing of netdev.
Florian Pose <fp@igh-essen.com>
parents: 1500
diff changeset
   311
        dev_kfree_skb(eoe->rx_skb);
c9e2c3be294e Later freeing of netdev.
Florian Pose <fp@igh-essen.com>
parents: 1500
diff changeset
   312
c9e2c3be294e Later freeing of netdev.
Florian Pose <fp@igh-essen.com>
parents: 1500
diff changeset
   313
    free_netdev(eoe->dev);
279
12f48c1cb143 Removed mbox_command out of slave.
Florian Pose <fp@igh-essen.com>
parents: 261
diff changeset
   314
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
   315
    ec_datagram_clear(&eoe->datagram);
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   316
}
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   317
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   318
/*****************************************************************************/
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   319
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   320
/** Empties the transmit queue.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   321
 */
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   322
void ec_eoe_flush(ec_eoe_t *eoe /**< EoE handler */)
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   323
{
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   324
    ec_eoe_frame_t *frame, *next;
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   325
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   326
    down(&eoe->tx_queue_sem);
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   327
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   328
    list_for_each_entry_safe(frame, next, &eoe->tx_queue, queue) {
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   329
        list_del(&frame->queue);
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   330
        dev_kfree_skb(frame->skb);
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   331
        kfree(frame);
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   332
    }
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   333
    eoe->tx_queued_frames = 0;
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   334
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   335
    up(&eoe->tx_queue_sem);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
}
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
/*****************************************************************************/
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   340
/** Sends a frame or the next fragment.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   341
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   342
 * \return Zero on success, otherwise a negative error code.
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   343
 */
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   344
int ec_eoe_send(ec_eoe_t *eoe /**< EoE handler */)
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   345
{
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   346
    size_t remaining_size, current_size, complete_offset;
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   347
    unsigned int last_fragment;
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   348
    uint8_t *data;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   349
#if EOE_DEBUG_LEVEL >= 3
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   350
    unsigned int i;
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   351
#endif
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   352
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   353
    remaining_size = eoe->tx_frame->skb->len - eoe->tx_offset;
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   354
1338
eb31b5a135da merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents: 1337
diff changeset
   355
    if (remaining_size <= eoe->slave->configured_tx_mailbox_size - 10) {
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   356
        current_size = remaining_size;
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   357
        last_fragment = 1;
1337
0253c74d0940 merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   358
    } else {
2626
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   359
        current_size =
713058b68b43 Fixed line wrapping.
Florian Pose <fp@igh-essen.com>
parents: 2625
diff changeset
   360
            ((eoe->slave->configured_tx_mailbox_size - 10) / 32) * 32;
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   361
        last_fragment = 0;
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   362
    }
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   363
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   364
    if (eoe->tx_fragment_number) {
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   365
        complete_offset = eoe->tx_offset / 32;
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   366
    }
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   367
    else {
319
88f2e8c4face Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 314
diff changeset
   368
        // complete size in 32 bit blocks, rounded up.
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   369
        complete_offset = remaining_size / 32 + 1;
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   370
    }
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   371
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   372
#if EOE_DEBUG_LEVEL >= 2
2644
0c3987a1b3ee Fixed EoE data debug level 3.
Florian Pose <fp@gh.de>
parents: 2641
diff changeset
   373
    EC_SLAVE_DBG(eoe->slave, 0, "EoE %s TX sending fragment %u%s"
0c3987a1b3ee Fixed EoE data debug level 3.
Florian Pose <fp@gh.de>
parents: 2641
diff changeset
   374
            " with %zu octets (%zu). %u frames queued.\n",
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   375
            eoe->dev->name, eoe->tx_fragment_number,
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   376
            last_fragment ? "" : "+", current_size, complete_offset,
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   377
            eoe->tx_queued_frames);
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   378
#endif
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   379
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   380
#if EOE_DEBUG_LEVEL >= 3
2644
0c3987a1b3ee Fixed EoE data debug level 3.
Florian Pose <fp@gh.de>
parents: 2641
diff changeset
   381
    EC_SLAVE_DBG(eoe->slave, 0, "");
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   382
    for (i = 0; i < current_size; i++) {
340
5a5f5a14c847 Fixed EoE debugging.
Florian Pose <fp@igh-essen.com>
parents: 339
diff changeset
   383
        printk("%02X ", eoe->tx_frame->skb->data[eoe->tx_offset + i]);
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   384
        if ((i + 1) % 16 == 0) {
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   385
            printk("\n");
2644
0c3987a1b3ee Fixed EoE data debug level 3.
Florian Pose <fp@gh.de>
parents: 2641
diff changeset
   386
            EC_SLAVE_DBG(eoe->slave, 0, "");
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   387
        }
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   388
    }
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   389
    printk("\n");
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   390
#endif
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   391
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   392
    data = ec_slave_mbox_prepare_send(eoe->slave, &eoe->datagram,
2591
23b360e4a530 Centrally defined mailbox types.
Florian Pose <fp@igh-essen.com>
parents: 2589
diff changeset
   393
            EC_MBOX_TYPE_EOE, current_size + 4);
2650
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   394
    if (IS_ERR(data)) {
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1209
diff changeset
   395
        return PTR_ERR(data);
2650
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   396
    }
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   397
2593
e2388daebfbc Cleaned up EoE frame type definitions.
Florian Pose <fp@igh-essen.com>
parents: 2592
diff changeset
   398
    EC_WRITE_U8 (data, EC_EOE_FRAMETYPE_INIT_REQ); // Initiate EoE Request
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   399
    EC_WRITE_U8 (data + 1, last_fragment);
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   400
    EC_WRITE_U16(data + 2, ((eoe->tx_fragment_number & 0x3F) |
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   401
                            (complete_offset & 0x3F) << 6 |
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   402
                            (eoe->tx_frame_number & 0x0F) << 12));
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   403
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   404
    memcpy(data + 4, eoe->tx_frame->skb->data + eoe->tx_offset, current_size);
721
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   405
    eoe->queue_datagram = 1;
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   406
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   407
    eoe->tx_offset += current_size;
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   408
    eoe->tx_fragment_number++;
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   409
    return 0;
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   410
}
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   411
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   412
/*****************************************************************************/
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   413
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   414
/** Runs the EoE state machine.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   415
 */
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   416
void ec_eoe_run(ec_eoe_t *eoe /**< EoE handler */)
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   417
{
2650
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   418
    if (!eoe->opened) {
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   419
        return;
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   420
    }
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
721
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   422
    // if the datagram was not sent, or is not yet received, skip this cycle
2650
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   423
    if (eoe->queue_datagram || eoe->datagram.state == EC_DATAGRAM_SENT) {
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   424
        return;
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   425
    }
721
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   426
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   427
    // call state function
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   428
    eoe->state(eoe);
336
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   429
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   430
    // update statistics
344
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 340
diff changeset
   431
    if (jiffies - eoe->rate_jiffies > HZ) {
1485
5ddc3a455059 ethercat eoe command.
Florian Pose <fp@igh-essen.com>
parents: 1484
diff changeset
   432
        eoe->rx_rate = eoe->rx_counter;
5ddc3a455059 ethercat eoe command.
Florian Pose <fp@igh-essen.com>
parents: 1484
diff changeset
   433
        eoe->tx_rate = eoe->tx_counter;
336
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   434
        eoe->rx_counter = 0;
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   435
        eoe->tx_counter = 0;
344
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 340
diff changeset
   436
        eoe->rate_jiffies = jiffies;
336
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   437
    }
721
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   438
719
03d5b96632fb Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents: 712
diff changeset
   439
    ec_datagram_output_stats(&eoe->datagram);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
}
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
/*****************************************************************************/
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   444
/** Queues the datagram, if necessary.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   445
 */
721
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   446
void ec_eoe_queue(ec_eoe_t *eoe /**< EoE handler */)
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   447
{
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   448
   if (eoe->queue_datagram) {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   449
       ec_master_queue_datagram_ext(eoe->slave->master, &eoe->datagram);
721
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   450
       eoe->queue_datagram = 0;
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   451
   }
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   452
}
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   453
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   454
/*****************************************************************************/
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   455
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   456
/** Returns the state of the device.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   457
 *
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   458
 * \return 1 if the device is "up", 0 if it is "down"
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   459
 */
661
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   460
int ec_eoe_is_open(const ec_eoe_t *eoe /**< EoE handler */)
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   461
{
bc1de1362efb Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
   462
    return eoe->opened;
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   463
}
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   464
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   465
/*****************************************************************************/
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   466
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   467
/** Returns the idle state.
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   468
 *
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   469
 * \retval 1 The device is idle.
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   470
 * \retval 0 The device is busy.
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   471
 */
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   472
int ec_eoe_is_idle(const ec_eoe_t *eoe /**< EoE handler */)
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   473
{
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   474
    return eoe->rx_idle && eoe->tx_idle;
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   475
}
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   476
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   477
/******************************************************************************
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   478
 *  STATE PROCESSING FUNCTIONS
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   479
 *****************************************************************************/
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   480
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   481
/** State: RX_START.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   482
 *
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   483
 * Starts a new receiving sequence by queueing a datagram that checks the
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   484
 * slave's mailbox for a new EoE datagram.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   485
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   486
 * \todo Use both devices.
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   487
 */
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   488
void ec_eoe_state_rx_start(ec_eoe_t *eoe /**< EoE handler */)
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   489
{
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   490
    if (eoe->slave->error_flag ||
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   491
            !eoe->slave->master->devices[EC_DEVICE_MAIN].link_state) {
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   492
        eoe->rx_idle = 1;
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   493
        eoe->tx_idle = 1;
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   494
        return;
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   495
    }
261
44a3a5833c49 Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents: 251
diff changeset
   496
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   497
    ec_slave_mbox_prepare_check(eoe->slave, &eoe->datagram);
721
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   498
    eoe->queue_datagram = 1;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   499
    eoe->state = ec_eoe_state_rx_check;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   500
}
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   501
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   502
/*****************************************************************************/
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   503
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   504
/** State: RX_CHECK.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   505
 *
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   506
 * Processes the checking datagram sent in RX_START and issues a receive
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   507
 * datagram, if new data is available.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   508
 */
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   509
void ec_eoe_state_rx_check(ec_eoe_t *eoe /**< EoE handler */)
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   510
{
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   511
    if (eoe->datagram.state != EC_DATAGRAM_RECEIVED) {
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   512
        eoe->stats.rx_errors++;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   513
#if EOE_DEBUG_LEVEL >= 1
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   514
        EC_SLAVE_WARN(eoe->slave, "Failed to receive mbox"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   515
                " check datagram for %s.\n", eoe->dev->name);
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   516
#endif
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   517
        eoe->state = ec_eoe_state_tx_start;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   518
        return;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   519
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   520
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   521
    if (!ec_slave_mbox_check(&eoe->datagram)) {
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   522
        eoe->rx_idle = 1;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   523
        eoe->state = ec_eoe_state_tx_start;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   524
        return;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   525
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   526
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   527
    eoe->rx_idle = 0;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   528
    ec_slave_mbox_prepare_fetch(eoe->slave, &eoe->datagram);
721
ebc2fd3e09e5 Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents: 719
diff changeset
   529
    eoe->queue_datagram = 1;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   530
    eoe->state = ec_eoe_state_rx_fetch;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   531
}
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   532
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   533
/*****************************************************************************/
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   534
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   535
/** State: RX_FETCH.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   536
 *
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   537
 * Checks if the requested data of RX_CHECK was received and processes the EoE
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   538
 * datagram.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   539
 */
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   540
void ec_eoe_state_rx_fetch(ec_eoe_t *eoe /**< EoE handler */)
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   541
{
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   542
    size_t rec_size, data_size;
391
7d67195702dd Removed additional loop in coe_down FSM; renamed mbox_type to mbox_prot.
Florian Pose <fp@igh-essen.com>
parents: 390
diff changeset
   543
    uint8_t *data, frame_type, last_fragment, time_appended, mbox_prot;
2240
b45438edf869 Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents: 2094
diff changeset
   544
    uint8_t fragment_offset, fragment_number;
b45438edf869 Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents: 2094
diff changeset
   545
#if EOE_DEBUG_LEVEL >= 2
b45438edf869 Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents: 2094
diff changeset
   546
    uint8_t frame_number;
b45438edf869 Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents: 2094
diff changeset
   547
#endif
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   548
    off_t offset;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   549
#if EOE_DEBUG_LEVEL >= 3
340
5a5f5a14c847 Fixed EoE debugging.
Florian Pose <fp@igh-essen.com>
parents: 339
diff changeset
   550
    unsigned int i;
5a5f5a14c847 Fixed EoE debugging.
Florian Pose <fp@igh-essen.com>
parents: 339
diff changeset
   551
#endif
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   552
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   553
    if (eoe->datagram.state != EC_DATAGRAM_RECEIVED) {
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   554
        eoe->stats.rx_errors++;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   555
#if EOE_DEBUG_LEVEL >= 1
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   556
        EC_SLAVE_WARN(eoe->slave, "Failed to receive mbox"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   557
                " fetch datagram for %s.\n", eoe->dev->name);
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   558
#endif
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   559
        eoe->state = ec_eoe_state_tx_start;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   560
        return;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   561
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   562
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   563
    data = ec_slave_mbox_fetch(eoe->slave, &eoe->datagram,
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1209
diff changeset
   564
            &mbox_prot, &rec_size);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1209
diff changeset
   565
    if (IS_ERR(data)) {
390
685c267d80d8 Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents: 344
diff changeset
   566
        eoe->stats.rx_errors++;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   567
#if EOE_DEBUG_LEVEL >= 1
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   568
        EC_SLAVE_WARN(eoe->slave, "Invalid mailbox response for %s.\n",
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   569
                eoe->dev->name);
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   570
#endif
390
685c267d80d8 Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents: 344
diff changeset
   571
        eoe->state = ec_eoe_state_tx_start;
685c267d80d8 Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents: 344
diff changeset
   572
        return;
685c267d80d8 Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents: 344
diff changeset
   573
    }
685c267d80d8 Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents: 344
diff changeset
   574
2591
23b360e4a530 Centrally defined mailbox types.
Florian Pose <fp@igh-essen.com>
parents: 2589
diff changeset
   575
    if (mbox_prot != EC_MBOX_TYPE_EOE) { // FIXME mailbox handler necessary
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   576
        eoe->stats.rx_errors++;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   577
#if EOE_DEBUG_LEVEL >= 1
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   578
        EC_SLAVE_WARN(eoe->slave, "Other mailbox protocol response for %s.\n",
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   579
                eoe->dev->name);
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   580
#endif
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   581
        eoe->state = ec_eoe_state_tx_start;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   582
        return;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   583
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   584
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   585
    frame_type = EC_READ_U16(data) & 0x000F;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   586
2593
e2388daebfbc Cleaned up EoE frame type definitions.
Florian Pose <fp@igh-essen.com>
parents: 2592
diff changeset
   587
    if (frame_type != EC_EOE_FRAMETYPE_INIT_REQ) { // EoE Fragment Data
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   588
#if EOE_DEBUG_LEVEL >= 1
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   589
        EC_SLAVE_WARN(eoe->slave, "%s: Other frame received."
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   590
                " Dropping.\n", eoe->dev->name);
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   591
#endif
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   592
        eoe->stats.rx_dropped++;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   593
        eoe->state = ec_eoe_state_tx_start;
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   594
        return;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   595
    }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   596
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   597
    // EoE Fragment Request received
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   598
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   599
    last_fragment = (EC_READ_U16(data) >> 8) & 0x0001;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   600
    time_appended = (EC_READ_U16(data) >> 9) & 0x0001;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   601
    fragment_number = EC_READ_U16(data + 2) & 0x003F;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   602
    fragment_offset = (EC_READ_U16(data + 2) >> 6) & 0x003F;
2240
b45438edf869 Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents: 2094
diff changeset
   603
#if EOE_DEBUG_LEVEL >= 2
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   604
    frame_number = (EC_READ_U16(data + 2) >> 12) & 0x000F;
2240
b45438edf869 Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents: 2094
diff changeset
   605
#endif
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   606
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   607
#if EOE_DEBUG_LEVEL >= 2
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   608
    EC_SLAVE_DBG(eoe->slave, 0, "EoE %s RX fragment %u%s, offset %u,"
2644
0c3987a1b3ee Fixed EoE data debug level 3.
Florian Pose <fp@gh.de>
parents: 2641
diff changeset
   609
            " frame %u%s, %zu octets\n", eoe->dev->name, fragment_number,
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   610
           last_fragment ? "" : "+", fragment_offset, frame_number,
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   611
           time_appended ? ", + timestamp" : "",
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   612
           time_appended ? rec_size - 8 : rec_size - 4);
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   613
#endif
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   614
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   615
#if EOE_DEBUG_LEVEL >= 3
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   616
    EC_SLAVE_DBG(eoe->slave, 0, "");
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   617
    for (i = 0; i < rec_size - 4; i++) {
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   618
        printk("%02X ", data[i + 4]);
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   619
        if ((i + 1) % 16 == 0) {
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   620
            printk("\n");
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   621
            EC_SLAVE_DBG(eoe->slave, 0, "");
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   622
        }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   623
    }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   624
    printk("\n");
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   625
#endif
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   626
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   627
    data_size = time_appended ? rec_size - 8 : rec_size - 4;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   628
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   629
    if (!fragment_number) {
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   630
        if (eoe->rx_skb) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   631
            EC_SLAVE_WARN(eoe->slave, "EoE RX freeing old socket buffer.\n");
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   632
            dev_kfree_skb(eoe->rx_skb);
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   633
        }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   634
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   635
        // new socket buffer
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   636
        if (!(eoe->rx_skb = dev_alloc_skb(fragment_offset * 32))) {
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   637
            if (printk_ratelimit())
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   638
                EC_SLAVE_WARN(eoe->slave, "EoE RX low on mem,"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   639
                        " frame dropped.\n");
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   640
            eoe->stats.rx_dropped++;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   641
            eoe->state = ec_eoe_state_tx_start;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   642
            return;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   643
        }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   644
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   645
        eoe->rx_skb_offset = 0;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   646
        eoe->rx_skb_size = fragment_offset * 32;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   647
        eoe->rx_expected_fragment = 0;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   648
    }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   649
    else {
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   650
        if (!eoe->rx_skb) {
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   651
            eoe->stats.rx_dropped++;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   652
            eoe->state = ec_eoe_state_tx_start;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   653
            return;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   654
        }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   655
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   656
        offset = fragment_offset * 32;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   657
        if (offset != eoe->rx_skb_offset ||
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   658
            offset + data_size > eoe->rx_skb_size ||
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   659
            fragment_number != eoe->rx_expected_fragment) {
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   660
            dev_kfree_skb(eoe->rx_skb);
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   661
            eoe->rx_skb = NULL;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   662
            eoe->stats.rx_errors++;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   663
#if EOE_DEBUG_LEVEL >= 1
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   664
            EC_SLAVE_WARN(eoe->slave, "Fragmenting error at %s.\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   665
                    eoe->dev->name);
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   666
#endif
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   667
            eoe->state = ec_eoe_state_tx_start;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   668
            return;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   669
        }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   670
    }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   671
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   672
    // copy fragment into socket buffer
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   673
    memcpy(skb_put(eoe->rx_skb, data_size), data + 4, data_size);
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   674
    eoe->rx_skb_offset += data_size;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   675
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   676
    if (last_fragment) {
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   677
        // update statistics
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   678
        eoe->stats.rx_packets++;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   679
        eoe->stats.rx_bytes += eoe->rx_skb->len;
336
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   680
        eoe->rx_counter += eoe->rx_skb->len;
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   681
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   682
#if EOE_DEBUG_LEVEL >= 2
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   683
        EC_SLAVE_DBG(eoe->slave, 0, "EoE %s RX frame completed"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   684
                " with %u octets.\n", eoe->dev->name, eoe->rx_skb->len);
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   685
#endif
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   686
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   687
        // pass socket buffer to network stack
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   688
        eoe->rx_skb->dev = eoe->dev;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   689
        eoe->rx_skb->protocol = eth_type_trans(eoe->rx_skb, eoe->dev);
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   690
        eoe->rx_skb->ip_summed = CHECKSUM_UNNECESSARY;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   691
        if (netif_rx(eoe->rx_skb)) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   692
            EC_SLAVE_WARN(eoe->slave, "EoE RX netif_rx failed.\n");
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   693
        }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   694
        eoe->rx_skb = NULL;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   695
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   696
        eoe->state = ec_eoe_state_tx_start;
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   697
    }
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   698
    else {
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   699
        eoe->rx_expected_fragment++;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   700
#if EOE_DEBUG_LEVEL >= 2
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   701
        EC_SLAVE_DBG(eoe->slave, 0, "EoE %s RX expecting fragment %u\n",
770
efa5af306318 Improved EoE debugging.
Florian Pose <fp@igh-essen.com>
parents: 721
diff changeset
   702
               eoe->dev->name, eoe->rx_expected_fragment);
322
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   703
#endif
fceb7b6e0a06 Improved EoE state machine.
Florian Pose <fp@igh-essen.com>
parents: 319
diff changeset
   704
        eoe->state = ec_eoe_state_rx_start;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   705
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   706
}
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   707
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   708
/*****************************************************************************/
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   709
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   710
/** State: TX START.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   711
 *
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   712
 * Starts a new transmit sequence. If no data is available, a new receive
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   713
 * sequence is started instead.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   714
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   715
 * \todo Use both devices.
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   716
 */
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   717
void ec_eoe_state_tx_start(ec_eoe_t *eoe /**< EoE handler */)
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   718
{
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   719
#if EOE_DEBUG_LEVEL >= 2
340
5a5f5a14c847 Fixed EoE debugging.
Florian Pose <fp@igh-essen.com>
parents: 339
diff changeset
   720
    unsigned int wakeup = 0;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   721
#endif
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   722
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   723
    if (eoe->slave->error_flag ||
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   724
            !eoe->slave->master->devices[EC_DEVICE_MAIN].link_state) {
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   725
        eoe->rx_idle = 1;
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   726
        eoe->tx_idle = 1;
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   727
        return;
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   728
    }
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   729
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   730
    down(&eoe->tx_queue_sem);
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   731
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   732
    if (!eoe->tx_queued_frames || list_empty(&eoe->tx_queue)) {
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   733
        up(&eoe->tx_queue_sem);
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   734
        eoe->tx_idle = 1;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   735
        // no data available.
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   736
        // start a new receive immediately.
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   737
        ec_eoe_state_rx_start(eoe);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   738
        return;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   739
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   740
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   741
    // take the first frame out of the queue
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   742
    eoe->tx_frame = list_entry(eoe->tx_queue.next, ec_eoe_frame_t, queue);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   743
    list_del(&eoe->tx_frame->queue);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   744
    if (!eoe->tx_queue_active &&
1485
5ddc3a455059 ethercat eoe command.
Florian Pose <fp@igh-essen.com>
parents: 1484
diff changeset
   745
        eoe->tx_queued_frames == eoe->tx_queue_size / 2) {
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   746
        netif_wake_queue(eoe->dev);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   747
        eoe->tx_queue_active = 1;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   748
#if EOE_DEBUG_LEVEL >= 2
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   749
        wakeup = 1;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   750
#endif
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   751
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   752
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   753
    eoe->tx_queued_frames--;
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   754
    up(&eoe->tx_queue_sem);
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   755
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   756
    eoe->tx_idle = 0;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   757
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   758
    eoe->tx_frame_number++;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   759
    eoe->tx_frame_number %= 16;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   760
    eoe->tx_fragment_number = 0;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   761
    eoe->tx_offset = 0;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   762
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   763
    if (ec_eoe_send(eoe)) {
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   764
        dev_kfree_skb(eoe->tx_frame->skb);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   765
        kfree(eoe->tx_frame);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   766
        eoe->tx_frame = NULL;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   767
        eoe->stats.tx_errors++;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   768
        eoe->state = ec_eoe_state_rx_start;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   769
#if EOE_DEBUG_LEVEL >= 1
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   770
        EC_SLAVE_WARN(eoe->slave, "Send error at %s.\n", eoe->dev->name);
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   771
#endif
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   772
        return;
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   773
    }
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   774
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   775
#if EOE_DEBUG_LEVEL >= 2
1484
1c9151455b65 Debug statements with EC_DBG() in EoE code.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   776
    if (wakeup)
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   777
        EC_SLAVE_DBG(eoe->slave, 0, "EoE %s waking up TX queue...\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   778
                eoe->dev->name);
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   779
#endif
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   780
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   781
    eoe->tries = EC_EOE_TRIES;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   782
    eoe->state = ec_eoe_state_tx_sent;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   783
}
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   784
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   785
/*****************************************************************************/
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   786
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   787
/** State: TX SENT.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   788
 *
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   789
 * Checks is the previous transmit datagram succeded and sends the next
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   790
 * fragment, if necessary.
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   791
 */
251
c1d0b63a9302 EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
   792
void ec_eoe_state_tx_sent(ec_eoe_t *eoe /**< EoE handler */)
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   793
{
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   794
    if (eoe->datagram.state != EC_DATAGRAM_RECEIVED) {
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   795
        if (eoe->tries) {
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   796
            eoe->tries--; // try again
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   797
            eoe->queue_datagram = 1;
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   798
        } else {
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   799
            eoe->stats.tx_errors++;
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   800
#if EOE_DEBUG_LEVEL >= 1
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   801
            EC_SLAVE_WARN(eoe->slave, "Failed to receive send"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   802
                    " datagram for %s after %u tries.\n",
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   803
                    eoe->dev->name, EC_EOE_TRIES);
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   804
#endif
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   805
            eoe->state = ec_eoe_state_rx_start;
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   806
        }
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   807
        return;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   808
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   809
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   810
    if (eoe->datagram.working_counter != 1) {
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   811
        if (eoe->tries) {
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   812
            eoe->tries--; // try again
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   813
            eoe->queue_datagram = 1;
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   814
        } else {
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   815
            eoe->stats.tx_errors++;
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   816
#if EOE_DEBUG_LEVEL >= 1
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   817
            EC_SLAVE_WARN(eoe->slave, "No sending response"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   818
                    " for %s after %u tries.\n",
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   819
                    eoe->dev->name, EC_EOE_TRIES);
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   820
#endif
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   821
            eoe->state = ec_eoe_state_rx_start;
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   822
        }
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   823
        return;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   824
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   825
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   826
    // frame completely sent
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   827
    if (eoe->tx_offset >= eoe->tx_frame->skb->len) {
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   828
        eoe->stats.tx_packets++;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   829
        eoe->stats.tx_bytes += eoe->tx_frame->skb->len;
336
360e5287c888 EoE rate statistics.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   830
        eoe->tx_counter += eoe->tx_frame->skb->len;
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   831
        dev_kfree_skb(eoe->tx_frame->skb);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   832
        kfree(eoe->tx_frame);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   833
        eoe->tx_frame = NULL;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   834
        eoe->state = ec_eoe_state_rx_start;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   835
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   836
    else { // send next fragment
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   837
        if (ec_eoe_send(eoe)) {
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   838
            dev_kfree_skb(eoe->tx_frame->skb);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   839
            kfree(eoe->tx_frame);
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   840
            eoe->tx_frame = NULL;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   841
            eoe->stats.tx_errors++;
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   842
#if EOE_DEBUG_LEVEL >= 1
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   843
            EC_SLAVE_WARN(eoe->slave, "Send error at %s.\n", eoe->dev->name);
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   844
#endif
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   845
            eoe->state = ec_eoe_state_rx_start;
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   846
        }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   847
    }
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   848
}
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   849
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   850
/******************************************************************************
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   851
 *  NET_DEVICE functions
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   852
 *****************************************************************************/
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   853
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   854
/** Opens the virtual network device.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   855
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   856
 * \return Always zero (success).
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   857
 */
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   858
int ec_eoedev_open(struct net_device *dev /**< EoE net_device */)
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   859
{
213
8d723b9833a9 removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents: 212
diff changeset
   860
    ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev));
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   861
    ec_eoe_flush(eoe);
212
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   862
    eoe->opened = 1;
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   863
    eoe->rx_idle = 0;
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   864
    eoe->tx_idle = 0;
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   865
    netif_start_queue(dev);
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   866
    eoe->tx_queue_active = 1;
1488
3fb343e3fac0 Output device opened/closed only on debug level 2.
Florian Pose <fp@igh-essen.com>
parents: 1487
diff changeset
   867
#if EOE_DEBUG_LEVEL >= 2
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   868
    EC_SLAVE_DBG(eoe->slave, 0, "%s opened.\n", dev->name);
1488
3fb343e3fac0 Output device opened/closed only on debug level 2.
Florian Pose <fp@igh-essen.com>
parents: 1487
diff changeset
   869
#endif
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   870
    return 0;
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   871
}
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   872
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   873
/*****************************************************************************/
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   874
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   875
/** Stops the virtual network device.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   876
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   877
 * \return Always zero (success).
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   878
 */
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   879
int ec_eoedev_stop(struct net_device *dev /**< EoE net_device */)
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   880
{
213
8d723b9833a9 removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents: 212
diff changeset
   881
    ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev));
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   882
    netif_stop_queue(dev);
1489
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   883
    eoe->rx_idle = 1;
f77a1182b6f4 EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents: 1488
diff changeset
   884
    eoe->tx_idle = 1;
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   885
    eoe->tx_queue_active = 0;
212
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   886
    eoe->opened = 0;
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   887
    ec_eoe_flush(eoe);
1488
3fb343e3fac0 Output device opened/closed only on debug level 2.
Florian Pose <fp@igh-essen.com>
parents: 1487
diff changeset
   888
#if EOE_DEBUG_LEVEL >= 2
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   889
    EC_SLAVE_DBG(eoe->slave, 0, "%s stopped.\n", dev->name);
1488
3fb343e3fac0 Output device opened/closed only on debug level 2.
Florian Pose <fp@igh-essen.com>
parents: 1487
diff changeset
   890
#endif
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   891
    return 0;
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   892
}
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   893
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   894
/*****************************************************************************/
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   895
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   896
/** Transmits data via the virtual network device.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   897
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   898
 * \return Zero on success, non-zero on failure.
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   899
 */
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   900
int ec_eoedev_tx(struct sk_buff *skb, /**< transmit socket buffer */
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   901
                 struct net_device *dev /**< EoE net_device */
212
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   902
                )
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   903
{
213
8d723b9833a9 removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents: 212
diff changeset
   904
    ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev));
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   905
    ec_eoe_frame_t *frame;
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   906
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   907
#if 0
1338
eb31b5a135da merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents: 1337
diff changeset
   908
    if (skb->len > eoe->slave->configured_tx_mailbox_size - 10) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   909
        EC_SLAVE_WARN(eoe->slave, "EoE TX frame (%u octets)"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   910
                " exceeds MTU. dropping.\n", skb->len);
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   911
        dev_kfree_skb(skb);
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   912
        eoe->stats.tx_dropped++;
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   913
        return 0;
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   914
    }
217
dcfd406e7786 EoE - TX fragmenting works. TCP traffic possible.
Florian Pose <fp@igh-essen.com>
parents: 216
diff changeset
   915
#endif
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   916
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   917
    if (!(frame =
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   918
          (ec_eoe_frame_t *) kmalloc(sizeof(ec_eoe_frame_t), GFP_ATOMIC))) {
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   919
        if (printk_ratelimit())
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   920
            EC_SLAVE_WARN(eoe->slave, "EoE TX: low on mem. frame dropped.\n");
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   921
        return 1;
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   922
    }
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   923
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   924
    frame->skb = skb;
212
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   925
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   926
    down(&eoe->tx_queue_sem);
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   927
    list_add_tail(&frame->queue, &eoe->tx_queue);
218
80fb87518f3d EoE: State machine with function pointers, documentation.
Florian Pose <fp@igh-essen.com>
parents: 217
diff changeset
   928
    eoe->tx_queued_frames++;
1485
5ddc3a455059 ethercat eoe command.
Florian Pose <fp@igh-essen.com>
parents: 1484
diff changeset
   929
    if (eoe->tx_queued_frames == eoe->tx_queue_size) {
212
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   930
        netif_stop_queue(dev);
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   931
        eoe->tx_queue_active = 0;
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   932
    }
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   933
    up(&eoe->tx_queue_sem);
212
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   934
1486
dac749e74956 EoE transmit retry; EoE warnings.
Florian Pose <fp@igh-essen.com>
parents: 1485
diff changeset
   935
#if EOE_DEBUG_LEVEL >= 2
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   936
    EC_SLAVE_DBG(eoe->slave, 0, "EoE %s TX queued frame"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   937
            " with %u octets (%u frames queued).\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   938
            eoe->dev->name, skb->len, eoe->tx_queued_frames);
2650
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   939
    if (!eoe->tx_queue_active) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1909
diff changeset
   940
        EC_SLAVE_WARN(eoe->slave, "EoE TX queue is now full.\n");
2650
0dc0873d4aed Minor changes.
Florian Pose <fp@igh-essen.com>
parents: 2645
diff changeset
   941
    }
215
b021aa6eee38 EoE: TCP traffic possible; TX fragmenting to do.
Florian Pose <fp@igh-essen.com>
parents: 214
diff changeset
   942
#endif
214
8beb86af5ed0 EoE frame queuing, receiving of fragmented frames; no TCP possible yet.
Florian Pose <fp@igh-essen.com>
parents: 213
diff changeset
   943
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   944
    return 0;
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   945
}
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   946
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   947
/*****************************************************************************/
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   948
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   949
/** Gets statistics about the virtual network device.
2589
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   950
 *
2b9c78543663 Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents: 2240
diff changeset
   951
 * \return Statistics.
1487
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   952
 */
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   953
struct net_device_stats *ec_eoedev_stats(
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   954
        struct net_device *dev /**< EoE net_device */
1c67e19f24b8 Minor: Changed comment style.
Florian Pose <fp@igh-essen.com>
parents: 1486
diff changeset
   955
        )
203
c1f305e339c6 EoE net_device implementation.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   956
{
213
8d723b9833a9 removed unnecessary private structure in eoe net_device.
Florian Pose <fp@igh-essen.com>
parents: 212
diff changeset
   957
    ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev));
212
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   958
    return &eoe->stats;
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   959
}
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   960
82980deb8b00 moved stats into eoe struct; persistent rx-skb; tx queue.
Florian Pose <fp@igh-essen.com>
parents: 210
diff changeset
   961
/*****************************************************************************/