IgH EtherCAT Master  1.7.0
ethernet.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_ETHERNET_H__
30#define __EC_ETHERNET_H__
31
32#include <linux/list.h>
33#include <linux/netdevice.h>
34
35#include "globals.h"
36#include "slave.h"
37#include "datagram.h"
38#include "fsm_mbox.h"
39
40/****************************************************************************/
41
44enum {
45 EC_EOE_FRAMETYPE_INIT_REQ = 0x00,
50};
51
52/****************************************************************************/
53
57
58typedef struct
59{
60 struct list_head queue;
61 struct sk_buff *skb;
62}
64
65/****************************************************************************/
66
67typedef struct ec_eoe ec_eoe_t;
68
74
75struct ec_eoe
76{
77 struct list_head list;
80 unsigned int queue_datagram;
81 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;
87
88 struct sk_buff *rx_skb;
90 size_t rx_skb_size;
92 uint32_t rx_counter;
93 uint32_t rx_rate;
94 unsigned int rx_idle;
95
96 struct list_head tx_queue;
97 unsigned int tx_queue_size;
98 unsigned int tx_queue_active;
99 unsigned int tx_queued_frames;
103 size_t tx_offset;
104 uint32_t tx_counter;
105 uint32_t tx_rate;
106 unsigned int tx_idle;
107
108 unsigned int tries;
109};
110
111/****************************************************************************/
112
114void ec_eoe_clear(ec_eoe_t *);
115void ec_eoe_run(ec_eoe_t *);
116void ec_eoe_queue(ec_eoe_t *);
117int ec_eoe_is_open(const ec_eoe_t *);
119int ec_eoe_is_idle(const ec_eoe_t *);
120
121/****************************************************************************/
122
123#endif
124
125/****************************************************************************/
EtherCAT datagram structure.
int ec_eoe_is_open(const ec_eoe_t *eoe)
Returns the state of the device.
Definition ethernet.c:408
void ec_eoe_run(ec_eoe_t *eoe)
Runs the EoE state machine.
Definition ethernet.c:351
void ec_eoe_clear(ec_eoe_t *eoe)
EoE destructor.
Definition ethernet.c:229
int ec_eoe_holds_mbox_lock(const ec_eoe_t *eoe)
Returns, if the handler holds the mailbox read lock of its slave.
Definition ethernet.c:421
int ec_eoe_init(ec_eoe_t *eoe, ec_slave_t *slave)
EoE constructor.
Definition ethernet.c:111
void ec_eoe_queue(ec_eoe_t *eoe)
Queues the datagram, if necessary.
Definition ethernet.c:394
int ec_eoe_is_idle(const ec_eoe_t *eoe)
Returns the idle state.
Definition ethernet.c:433
struct ec_eoe ec_eoe_t
Definition ethernet.h:67
@ EC_EOE_FRAMETYPE_FILT_RES
Set Address Filter Request.
Definition ethernet.h:49
@ EC_EOE_FRAMETYPE_FILT_REQ
Set IP Parameter Response.
Definition ethernet.h:48
@ EC_EOE_FRAMETYPE_SET_IP_RES
Set IP Parameter Request.
Definition ethernet.h:47
@ EC_EOE_FRAMETYPE_SET_IP_REQ
Initiate EoE Request.
Definition ethernet.h:46
EtherCAT mailbox receive state machine.
struct ec_fsm_mbox ec_fsm_mbox_t
Definition fsm_mbox.h:47
Global definitions and macros.
struct ec_slave ec_slave_t
Definition globals.h:315
EtherCAT slave structure.
EtherCAT datagram.
Definition datagram.h:81
Queued frame structure.
Definition ethernet.h:59
struct list_head queue
list item
Definition ethernet.h:60
struct sk_buff * skb
socket buffer
Definition ethernet.h:61
Ethernet over EtherCAT (EoE) handler.
Definition ethernet.h:76
uint32_t rx_rate
receive rate (bps)
Definition ethernet.h:93
unsigned int tx_queue_active
kernel netif queue started
Definition ethernet.h:98
unsigned int opened
net_device is opened
Definition ethernet.h:85
unsigned int queue_datagram
the datagram is ready for queuing
Definition ethernet.h:80
unsigned int tx_queued_frames
number of frames in the queue
Definition ethernet.h:99
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:78
size_t rx_skb_size
size of the allocated socket buffer memory
Definition ethernet.h:90
unsigned int tx_idle
Idle flag.
Definition ethernet.h:106
ec_datagram_t datagram
datagram
Definition ethernet.h:79
ec_eoe_frame_t * tx_frame
current TX frame
Definition ethernet.h:100
off_t rx_skb_offset
current write pointer in the socket buffer
Definition ethernet.h:89
size_t tx_offset
number of octets sent
Definition ethernet.h:103
struct net_device_stats stats
device statistics
Definition ethernet.h:84
uint8_t rx_expected_fragment
next expected fragment number
Definition ethernet.h:91
uint32_t rx_counter
octets received during last second
Definition ethernet.h:92
unsigned int tries
Tries.
Definition ethernet.h:108
ec_fsm_mbox_t fsm_mbox
Mailbox receive state machine.
Definition ethernet.h:82
struct net_device * dev
net_device for virtual ethernet device
Definition ethernet.h:83
uint8_t tx_frame_number
number of the transmitted frame
Definition ethernet.h:101
uint32_t tx_counter
octets transmitted during last second
Definition ethernet.h:104
struct sk_buff * rx_skb
current rx socket buffer
Definition ethernet.h:88
unsigned long rate_jiffies
time of last rate output
Definition ethernet.h:86
uint32_t tx_rate
transmit rate (bps)
Definition ethernet.h:105
unsigned int tx_queue_size
Transmit queue size.
Definition ethernet.h:97
unsigned int rx_idle
Idle flag.
Definition ethernet.h:94
struct list_head list
list item
Definition ethernet.h:77
void(*) state(ec_eoe_t *)
state function for the state machine
Definition ethernet.h:81
struct list_head tx_queue
queue for frames to send
Definition ethernet.h:96