IgH EtherCAT Master  1.6.9
device.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH
4 *
5 * This file is part of the IgH EtherCAT Master.
6 *
7 * The IgH EtherCAT Master is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version 2, as
9 * published by the Free Software Foundation.
10 *
11 * The IgH EtherCAT Master is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 * Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with the IgH EtherCAT Master; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 ****************************************************************************/
21
26
27/****************************************************************************/
28
29#ifndef __EC_DEVICE_H__
30#define __EC_DEVICE_H__
31
32#include <linux/interrupt.h>
33
34#include "../devices/ecdev.h"
35#include "globals.h"
36
43#define EC_TX_RING_SIZE 2
44
45#ifdef EC_DEBUG_IF
46#include "debug.h"
47#endif
48
49#ifdef EC_DEBUG_RING
50#define EC_DEBUG_RING_SIZE 10
51
52typedef enum {
53 TX, RX
54} ec_debug_frame_dir_t;
55
56typedef struct {
57 ec_debug_frame_dir_t dir;
58 struct timeval t;
59 uint8_t data[EC_MAX_DATA_SIZE];
60 unsigned int data_size;
61} ec_debug_frame_t;
62
63#endif
64
65/****************************************************************************/
66
72
74{
76 struct net_device *dev;
78 struct module *module;
79 uint8_t open;
80 uint8_t link_state;
81 struct sk_buff *tx_skb[EC_TX_RING_SIZE];
82 unsigned int tx_ring_index;
83#ifdef EC_HAVE_CYCLES
84 cycles_t cycles_poll;
85#endif
86#ifdef EC_DEBUG_RING
87 struct timeval timeval_poll;
88#endif
89 unsigned long jiffies_poll;
90
91 // Frame statistics
113
114#ifdef EC_DEBUG_IF
115 ec_debug_t dbg;
116#endif
117#ifdef EC_DEBUG_RING
118 ec_debug_frame_t debug_frames[EC_DEBUG_RING_SIZE];
119 unsigned int debug_frame_index;
120 unsigned int debug_frame_count;
121#endif
122};
123
124/****************************************************************************/
125
128
129void ec_device_attach(ec_device_t *, struct net_device *, ec_pollfunc_t,
130 struct module *);
132
135
138void ec_device_send(ec_device_t *, size_t);
141
142#ifdef EC_DEBUG_RING
143void ec_device_debug_ring_append(ec_device_t *, ec_debug_frame_dir_t,
144 const void *, size_t);
145void ec_device_debug_ring_print(const ec_device_t *);
146#endif
147
148/****************************************************************************/
149
150#endif
Network interface for debugging purposes.
int ec_device_init(ec_device_t *, ec_master_t *)
Constructor.
Definition device.c:60
void ec_device_clear_stats(ec_device_t *)
Clears the frame statistics.
Definition device.c:359
void ec_device_clear(ec_device_t *)
Destructor.
Definition device.c:159
uint8_t * ec_device_tx_data(ec_device_t *)
Returns a pointer to the device's transmit memory.
Definition device.c:301
void ec_device_update_stats(ec_device_t *)
Update device statistics.
Definition device.c:481
void ec_device_detach(ec_device_t *)
Disconnect from net_device.
Definition device.c:210
void ec_device_attach(ec_device_t *, struct net_device *, ec_pollfunc_t, struct module *)
Associate with net_device.
Definition device.c:179
#define EC_TX_RING_SIZE
Size of the transmit ring.
Definition device.h:43
int ec_device_open(ec_device_t *)
Opens the EtherCAT device.
Definition device.c:239
void ec_device_send(ec_device_t *, size_t)
Sends the content of the transmit socket buffer.
Definition device.c:320
void ec_device_poll(ec_device_t *)
Calls the poll function of the assigned net_device.
Definition device.c:463
int ec_device_close(ec_device_t *)
Stops the EtherCAT device.
Definition device.c:272
EtherCAT interface for EtherCAT device drivers.
void(* ec_pollfunc_t)(struct net_device *)
Device poll function type.
Definition ecdev.h:49
struct ec_device ec_device_t
Definition ecdev.h:45
Global definitions and macros.
#define EC_RATE_COUNT
Number of statistic rate intervals to maintain.
Definition globals.h:60
#define EC_MAX_DATA_SIZE
Resulting maximum data size of a single datagram in a frame.
Definition globals.h:79
struct ec_master ec_master_t
Definition ecrt.h:300
Debugging network interface.
Definition debug.h:39
EtherCAT device.
Definition device.h:74
u64 tx_errors
Number of transmit errors.
Definition device.h:102
uint8_t open
true, if the net_device has been opened
Definition device.h:79
u64 tx_count
Number of frames sent.
Definition device.h:92
s32 tx_frame_rates[EC_RATE_COUNT]
Transmit rates in frames/s for different statistics cycle periods.
Definition device.h:103
ec_master_t * master
EtherCAT master.
Definition device.h:75
u64 last_rx_bytes
Number of bytes received of last statistics cycle.
Definition device.h:100
s32 rx_byte_rates[EC_RATE_COUNT]
Receive rates in byte/s for different statistics cycle periods.
Definition device.h:111
u64 last_rx_count
Number of frames received of last statistics cycle.
Definition device.h:95
s32 tx_byte_rates[EC_RATE_COUNT]
Transmit rates in byte/s for different statistics cycle periods.
Definition device.h:109
struct sk_buff * tx_skb[EC_TX_RING_SIZE]
transmit skb ring
Definition device.h:81
struct module * module
pointer to the device's owning module
Definition device.h:78
s32 rx_frame_rates[EC_RATE_COUNT]
Receive rates in frames/s for different statistics cycle periods.
Definition device.h:106
struct net_device * dev
pointer to the assigned net_device
Definition device.h:76
u64 tx_bytes
Number of bytes sent.
Definition device.h:97
ec_pollfunc_t poll
pointer to the device's poll function
Definition device.h:77
u64 rx_count
Number of frames received.
Definition device.h:94
uint8_t link_state
device link state
Definition device.h:80
u64 last_tx_bytes
Number of bytes sent of last statistics cycle.
Definition device.h:98
unsigned int tx_ring_index
last ring entry used to transmit
Definition device.h:82
unsigned long jiffies_poll
jiffies of last poll
Definition device.h:89
u64 last_tx_count
Number of frames sent of last statistics cycle.
Definition device.h:93
u64 rx_bytes
Number of bytes received.
Definition device.h:99