IgH EtherCAT Master  1.5.2
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 #include "globals.h"
44 #include "locks.h"
45 #include "slave.h"
46 #include "datagram.h"
47 
48 /*****************************************************************************/
49 
52 enum {
53  EC_EOE_TYPE_FRAME_FRAG = 0x00,
59 };
60 
61 /*****************************************************************************/
62 
63 typedef struct ec_eoe ec_eoe_t;
71 struct ec_eoe
72 {
73  struct list_head list;
77  unsigned int queue_datagram;
78  void (*state)(ec_eoe_t *);
79  struct net_device *dev;
80  struct net_device_stats stats;
81  unsigned int opened;
82  unsigned long rate_jiffies;
83  unsigned int have_mbox_lock;
84  unsigned int auto_created;
86  struct sk_buff *rx_skb;
87  off_t rx_skb_offset;
88  size_t rx_skb_size;
90  uint32_t rx_counter;
91  uint32_t rx_rate;
92  unsigned int rx_idle;
94  struct sk_buff **tx_ring;
95  unsigned int tx_ring_count;
96  unsigned int tx_ring_size;
97  unsigned int tx_next_to_use;
98  unsigned int tx_next_to_clean;
99  unsigned int tx_queue_active;
100  struct sk_buff *tx_skb;
101  uint8_t tx_frame_number;
103  size_t tx_offset;
104  uint32_t tx_counter;
105  uint32_t tx_rate;
106  unsigned int tx_idle;
108  unsigned int tries;
109 };
110 
111 /*****************************************************************************/
112 
113 int ec_eoe_parse(const char *, int *, uint16_t *, uint16_t *);
114 
115 int ec_eoe_init(ec_master_t *, ec_eoe_t *, uint16_t/*alias*/, uint16_t/*posn*/);
119 void ec_eoe_clear(ec_eoe_t *);
120 void ec_eoe_run(ec_eoe_t *);
121 void ec_eoe_queue(ec_eoe_t *);
122 int ec_eoe_is_open(const ec_eoe_t *);
123 int ec_eoe_is_idle(const ec_eoe_t *);
124 char *ec_eoe_name(const ec_eoe_t *);
125 unsigned int ec_eoe_tx_queued_frames(const ec_eoe_t *);
126 
127 /*****************************************************************************/
128 
129 #endif
130 
131 /*****************************************************************************/
unsigned int tx_ring_size
Transmit ring size.
Definition: ethernet.h:96
int ec_eoe_init(ec_master_t *, ec_eoe_t *, uint16_t, uint16_t)
EoE explicit init constructor.
Definition: ethernet.c:207
uint32_t tx_counter
octets transmitted during last second
Definition: ethernet.h:104
void ec_eoe_clear(ec_eoe_t *)
EoE destructor.
Definition: ethernet.c:489
uint8_t tx_fragment_number
number of the fragment
Definition: ethernet.h:102
ec_slave_t * slave
pointer to the corresponding slave
Definition: ethernet.h:75
unsigned int tx_ring_count
Transmit ring count.
Definition: ethernet.h:95
size_t rx_skb_size
size of the allocated socket buffer memory
Definition: ethernet.h:88
size_t tx_offset
number of octets sent
Definition: ethernet.h:103
EtherCAT slave structure.
char * ec_eoe_name(const ec_eoe_t *)
Returns the eoe device name.
Definition: ethernet.c:716
EtherCAT datagram.
Definition: datagram.h:88
unsigned int tx_queue_active
kernel netif queue started
Definition: ethernet.h:99
void ec_eoe_link_slave(ec_eoe_t *, ec_slave_t *)
EoE link slave.
Definition: ethernet.c:412
uint32_t tx_rate
transmit rate (bps)
Definition: ethernet.h:105
Global definitions and macros.
uint8_t rx_expected_fragment
next expected fragment number
Definition: ethernet.h:89
void ec_eoe_run(ec_eoe_t *)
Runs the EoE state machine.
Definition: ethernet.c:649
EtherCAT slave.
Definition: slave.h:214
unsigned int tx_next_to_use
index of frames added to the ring
Definition: ethernet.h:97
unsigned int auto_created
auto created flag.
Definition: ethernet.h:84
int ec_eoe_is_open(const ec_eoe_t *)
Returns the state of the device.
Definition: ethernet.c:693
unsigned int tx_next_to_clean
index of frames being used from the ring
Definition: ethernet.h:98
unsigned long rate_jiffies
time of last rate output
Definition: ethernet.h:82
int ec_eoe_parse(const char *, int *, uint16_t *, uint16_t *)
Parse an eoe interface from a string.
Definition: ethernet.c:132
struct sk_buff ** tx_ring
ring for frames to send
Definition: ethernet.h:94
unsigned int have_mbox_lock
flag to track if we have the mbox lock
Definition: ethernet.h:83
ec_master_t * master
pointer to the corresponding master
Definition: ethernet.h:74
EoE Init, Set IP Parameter Request.
Definition: ethernet.h:56
void ec_eoe_queue(ec_eoe_t *)
Queues the datagram, if necessary.
Definition: ethernet.c:679
EtherCAT datagram structure.
int ec_eoe_auto_init(ec_eoe_t *, ec_slave_t *)
EoE auto constructor for slave.
Definition: ethernet.c:385
unsigned int opened
net_device is opened
Definition: ethernet.h:81
struct list_head list
list item
Definition: ethernet.h:73
int ec_eoe_is_idle(const ec_eoe_t *)
Returns the idle state.
Definition: ethernet.c:705
off_t rx_skb_offset
current write pointer in the socket buffer
Definition: ethernet.h:87
ec_datagram_t datagram
datagram
Definition: ethernet.h:76
unsigned int ec_eoe_tx_queued_frames(const ec_eoe_t *eoe)
Definition: ethernet.c:540
struct net_device_stats stats
device statistics
Definition: ethernet.h:80
unsigned int tx_idle
Idle flag.
Definition: ethernet.h:106
uint32_t rx_rate
receive rate (bps)
Definition: ethernet.h:91
void ec_eoe_clear_slave(ec_eoe_t *)
EoE clear slave.
Definition: ethernet.c:448
struct sk_buff * rx_skb
current rx socket buffer
Definition: ethernet.h:86
EoE Frame Fragment Tx & Rx.
Definition: ethernet.h:54
void(* state)(ec_eoe_t *)
state function for the state machine
Definition: ethernet.h:78
EoE Timestamp Response.
Definition: ethernet.h:55
struct sk_buff * tx_skb
current TX frame
Definition: ethernet.h:100
uint8_t tx_frame_number
number of the transmitted frame
Definition: ethernet.h:101
uint32_t rx_counter
octets received during last second
Definition: ethernet.h:90
EoE Init, Set IP Parameter Response.
Definition: ethernet.h:57
unsigned int tries
Tries.
Definition: ethernet.h:108
Abstract locks.
Ethernet over EtherCAT (EoE) handler.
Definition: ethernet.h:71
EoE Set MAC Address Filter Request.
Definition: ethernet.h:58
unsigned int rx_idle
Idle flag.
Definition: ethernet.h:92
EtherCAT master.
Definition: master.h:202
struct net_device * dev
net_device for virtual ethernet device
Definition: ethernet.h:79
unsigned int queue_datagram
the datagram is ready for queuing
Definition: ethernet.h:77