master/debug.c
author Florian Pose <fp@igh-essen.com>
Mon, 19 Jan 2009 14:46:55 +0000
branch1.4-foe
changeset 1709 63e4bc918640
parent 1685 399ef727bf62
permissions -rw-r--r--
Implemented going to bootstrap state BOOT.
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
1685
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
     5
 *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
1685
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    11
 *  published by the Free Software Foundation.
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    12
 *
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    16
 *  Public License for more details.
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    17
 *
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *
1685
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    22
 *  Using the EtherCAT technology and brand is permitted in compliance with
399ef727bf62 Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 687
diff changeset
    23
 *  the 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: 231
diff changeset
    24
 *
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *****************************************************************************/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
/**
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
   \file
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
   Ethernet interface for debugging purposes.
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
*/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
/*****************************************************************************/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
294
feea8d850c65 Applied include patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
    34
#include <linux/netdevice.h>
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#include <linux/etherdevice.h>
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#include "globals.h"
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
#include "debug.h"
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
/*****************************************************************************/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
// net_device functions
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
int ec_dbgdev_open(struct net_device *);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
int ec_dbgdev_stop(struct net_device *);
471
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
    45
int ec_dbgdev_tx(struct sk_buff *, struct net_device *);
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
struct net_device_stats *ec_dbgdev_stats(struct net_device *);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
/*****************************************************************************/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
/**
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
   Debug constructor.
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
   Initializes the debug object, creates a net_device and registeres it.
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
*/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
687
6de97f276423 Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 471
diff changeset
    55
int ec_debug_init(
6de97f276423 Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 471
diff changeset
    56
        ec_debug_t *dbg, /**< debug object */
6de97f276423 Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 471
diff changeset
    57
        const char *name /**< interface name */
6de97f276423 Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 471
diff changeset
    58
        )
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
{
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
    int result;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
    dbg->opened = 0;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
    memset(&dbg->stats, 0, sizeof(struct net_device_stats));
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
    if (!(dbg->dev =
687
6de97f276423 Changed names of debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 471
diff changeset
    66
          alloc_netdev(sizeof(ec_debug_t *), name, ether_setup))) {
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
        EC_ERR("Unable to allocate net_device for debug object!\n");
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
        goto out_return;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
    }
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
    // initialize net_device
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
    dbg->dev->open = ec_dbgdev_open;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
    dbg->dev->stop = ec_dbgdev_stop;
471
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
    74
    dbg->dev->hard_start_xmit = ec_dbgdev_tx;
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
    dbg->dev->get_stats = ec_dbgdev_stats;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
    // initialize private data
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
    *((ec_debug_t **) netdev_priv(dbg->dev)) = dbg;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
    // connect the net_device to the kernel
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
    if ((result = register_netdev(dbg->dev))) {
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
        EC_ERR("Unable to register net_device: error %i\n", result);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
        goto out_free;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
    }
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
    return 0;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
 out_free:
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
    free_netdev(dbg->dev);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
    dbg->dev = NULL;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
 out_return:
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
    return -1;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
}
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
/*****************************************************************************/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
/**
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
   Debug destructor.
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
   Unregisteres the net_device and frees allocated memory.
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
*/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
void ec_debug_clear(ec_debug_t *dbg /**< debug object */)
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
{
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
    if (dbg->dev) {
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
        unregister_netdev(dbg->dev);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
        free_netdev(dbg->dev);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
    }
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
}
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
/*****************************************************************************/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
/**
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
   Sends frame data to the interface.
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
*/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
void ec_debug_send(ec_debug_t *dbg, /**< debug object */
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
                   const uint8_t *data, /**< frame data */
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
                   size_t size /**< size of the frame data */
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
                   )
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
{
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
    struct sk_buff *skb;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
    if (!dbg->opened) return;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
    // allocate socket buffer
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
    if (!(skb = dev_alloc_skb(size))) {
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
        dbg->stats.rx_dropped++;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
        return;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
    }
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
    // copy frame contents into socket buffer
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
    memcpy(skb_put(skb, size), data, size);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
    // update device statistics
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
    dbg->stats.rx_packets++;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
    dbg->stats.rx_bytes += size;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
    // pass socket buffer to network stack
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
    skb->dev = dbg->dev;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
    skb->protocol = eth_type_trans(skb, dbg->dev);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
    skb->ip_summed = CHECKSUM_UNNECESSARY;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
    netif_rx(skb);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
}
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
/******************************************************************************
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
 *  NET_DEVICE functions
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
 *****************************************************************************/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
/**
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
   Opens the virtual network device.
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
*/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
int ec_dbgdev_open(struct net_device *dev /**< debug net_device */)
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
{
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
    ec_debug_t *dbg = *((ec_debug_t **) netdev_priv(dev));
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
    dbg->opened = 1;
455
204c435fddf9 Minor output changes in master/debug.c.
Florian Pose <fp@igh-essen.com>
parents: 294
diff changeset
   157
    EC_INFO("Debug interface %s opened.\n", dev->name);
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
    return 0;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
}
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
/*****************************************************************************/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
/**
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
   Stops the virtual network device.
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
*/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
int ec_dbgdev_stop(struct net_device *dev /**< debug net_device */)
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
{
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
    ec_debug_t *dbg = *((ec_debug_t **) netdev_priv(dev));
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
    dbg->opened = 0;
455
204c435fddf9 Minor output changes in master/debug.c.
Florian Pose <fp@igh-essen.com>
parents: 294
diff changeset
   171
    EC_INFO("Debug interface %s stopped.\n", dev->name);
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
    return 0;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
}
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
/*****************************************************************************/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
/**
471
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   178
   Transmits data via the virtual network device.
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   179
*/
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   180
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   181
int ec_dbgdev_tx(struct sk_buff *skb, /**< transmit socket buffer */
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   182
                 struct net_device *dev /**< EoE net_device */
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   183
                 )
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   184
{
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   185
    ec_debug_t *dbg = *((ec_debug_t **) netdev_priv(dev));
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   186
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   187
    dev_kfree_skb(skb);
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   188
    dbg->stats.tx_dropped++;
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   189
    return 0;
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   190
}
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   191
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   192
/*****************************************************************************/
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   193
0a6bd71bf4d3 Fixed debug interfaces.
Florian Pose <fp@igh-essen.com>
parents: 455
diff changeset
   194
/**
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
   Gets statistics about the virtual network device.
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
*/
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
struct net_device_stats *ec_dbgdev_stats(struct net_device *dev
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
                                         /**< debug net_device */)
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
{
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
    ec_debug_t *dbg = *((ec_debug_t **) netdev_priv(dev));
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
    return &dbg->stats;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
}
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
/*****************************************************************************/