IgH EtherCAT Master  1.5.3
ethernet.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * $Id$
4  *
5  * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH
6  *
7  * This file is part of the IgH EtherCAT Master.
8  *
9  * The IgH EtherCAT Master is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License version 2, as
11  * published by the Free Software Foundation.
12  *
13  * The IgH EtherCAT Master is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with the IgH EtherCAT Master; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * ---
23  *
24  * The license mentioned above concerns the source code only. Using the
25  * EtherCAT technology and brand is only permitted in compliance with the
26  * industrial property and similar rights of Beckhoff Automation GmbH.
27  *
28  *****************************************************************************/
29 
35 /*****************************************************************************/
36 
37 #ifndef __EC_ETHERNET_H__
38 #define __EC_ETHERNET_H__
39 
40 #include <linux/list.h>
41 #include <linux/netdevice.h>
42 
43 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
44 #include <linux/semaphore.h>
45 #else
46 #include <asm/semaphore.h>
47 #endif
48 
49 #include "globals.h"
50 #include "slave.h"
51 #include "datagram.h"
52 
53 /*****************************************************************************/
54 
59 typedef struct
60 {
61  struct list_head queue;
62  struct sk_buff *skb;
63 }
65 
66 /*****************************************************************************/
67 
68 typedef struct ec_eoe ec_eoe_t;
76 struct ec_eoe
77 {
78  struct list_head list;
81  unsigned int queue_datagram;
82  void (*state)(ec_eoe_t *);
83  struct net_device *dev;
84  struct net_device_stats stats;
85  unsigned int opened;
86  unsigned long rate_jiffies;
88  struct sk_buff *rx_skb;
89  off_t rx_skb_offset;
90  size_t rx_skb_size;
92  uint32_t rx_counter;
93  uint32_t rx_rate;
94  unsigned int rx_idle;
96  struct list_head tx_queue;
97  unsigned int tx_queue_size;
98  unsigned int tx_queue_active;
99  unsigned int tx_queued_frames;
100  struct semaphore tx_queue_sem;
102  uint8_t tx_frame_number;
104  size_t tx_offset;
105  uint32_t tx_counter;
106  uint32_t tx_rate;
107  unsigned int tx_idle;
109  unsigned int tries;
110 };
111 
112 /*****************************************************************************/
113 
115 void ec_eoe_clear(ec_eoe_t *);
116 void ec_eoe_run(ec_eoe_t *);
117 void ec_eoe_queue(ec_eoe_t *);
118 int ec_eoe_is_open(const ec_eoe_t *);
119 int ec_eoe_is_idle(const ec_eoe_t *);
120 
121 /*****************************************************************************/
122 
123 #endif
124 
125 /*****************************************************************************/
Queued frame structure.
Definition: ethernet.h:59
uint32_t tx_counter
octets transmitted during last second
Definition: ethernet.h:105
void ec_eoe_clear(ec_eoe_t *)
EoE destructor.
Definition: ethernet.c:234
struct sk_buff * skb
socket buffer
Definition: ethernet.h:62
struct list_head tx_queue
queue for frames to send
Definition: ethernet.h:96
uint8_t tx_fragment_number
number of the fragment
Definition: ethernet.h:103
ec_slave_t * slave
pointer to the corresponding slave
Definition: ethernet.h:79
unsigned int tx_queue_size
Transmit queue size.
Definition: ethernet.h:97
size_t rx_skb_size
size of the allocated socket buffer memory
Definition: ethernet.h:90
size_t tx_offset
number of octets sent
Definition: ethernet.h:104
EtherCAT slave structure.
EtherCAT datagram.
Definition: datagram.h:87
unsigned int tx_queue_active
kernel netif queue started
Definition: ethernet.h:98
uint32_t tx_rate
transmit rate (bps)
Definition: ethernet.h:106
Global definitions and macros.
uint8_t rx_expected_fragment
next expected fragment number
Definition: ethernet.h:91
void ec_eoe_run(ec_eoe_t *)
Runs the EoE state machine.
Definition: ethernet.c:351
EtherCAT slave.
Definition: slave.h:176
int ec_eoe_is_open(const ec_eoe_t *)
Returns the state of the device.
Definition: ethernet.c:393
unsigned long rate_jiffies
time of last rate output
Definition: ethernet.h:86
void ec_eoe_queue(ec_eoe_t *)
Queues the datagram, if necessary.
Definition: ethernet.c:379
EtherCAT datagram structure.
unsigned int opened
net_device is opened
Definition: ethernet.h:85
struct list_head list
list item
Definition: ethernet.h:78
int ec_eoe_is_idle(const ec_eoe_t *)
Returns the idle state.
Definition: ethernet.c:405
int ec_eoe_init(ec_eoe_t *, ec_slave_t *)
EoE constructor.
Definition: ethernet.c:114
off_t rx_skb_offset
current write pointer in the socket buffer
Definition: ethernet.h:89
ec_datagram_t datagram
datagram
Definition: ethernet.h:80
struct net_device_stats stats
device statistics
Definition: ethernet.h:84
unsigned int tx_idle
Idle flag.
Definition: ethernet.h:107
uint32_t rx_rate
receive rate (bps)
Definition: ethernet.h:93
struct sk_buff * rx_skb
current rx socket buffer
Definition: ethernet.h:88
void(* state)(ec_eoe_t *)
state function for the state machine
Definition: ethernet.h:82
uint8_t tx_frame_number
number of the transmitted frame
Definition: ethernet.h:102
uint32_t rx_counter
octets received during last second
Definition: ethernet.h:92
struct semaphore tx_queue_sem
Semaphore for the send queue.
Definition: ethernet.h:100
ec_eoe_frame_t * tx_frame
current TX frame
Definition: ethernet.h:101
unsigned int tries
Tries.
Definition: ethernet.h:109
Ethernet over EtherCAT (EoE) handler.
Definition: ethernet.h:76
unsigned int rx_idle
Idle flag.
Definition: ethernet.h:94
struct net_device * dev
net_device for virtual ethernet device
Definition: ethernet.h:83
unsigned int queue_datagram
the datagram is ready for queuing
Definition: ethernet.h:81
unsigned int tx_queued_frames
number of frames in the queue
Definition: ethernet.h:99