Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
etherlabmaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICS Control System Infrastructure
etherlabmaster
Commits
931066c2
Commit
931066c2
authored
16 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Ethernet devices.
parent
f5659967
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
documentation/ethercat_doc.tex
+118
-125
118 additions, 125 deletions
documentation/ethercat_doc.tex
with
118 additions
and
125 deletions
documentation/ethercat_doc.tex
+
118
−
125
View file @
931066c2
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
%
%
% $Id$
% $Id$
%
%
% vi: spell spelllang=en
%
%------------------------------------------------------------------------------
%------------------------------------------------------------------------------
%
%
...
@@ -320,7 +322,7 @@ EtherCAT functionality (see section~\ref{sec:ecrt}).
...
@@ -320,7 +322,7 @@ EtherCAT functionality (see section~\ref{sec:ecrt}).
\begin
{
itemize
}
\begin
{
itemize
}
\item
Master and network device configuration via
S
ysconfig files.
\item
Master and network device configuration via
s
ysconfig files.
\item
Init script for master control.
\item
Init script for master control.
...
@@ -719,18 +721,17 @@ respectively.
...
@@ -719,18 +721,17 @@ respectively.
\paragraph
{
Tasks of a Network Driver
}
\paragraph
{
Tasks of a Network Driver
}
Network device drivers handle the lower two layers of the OSI model,
Network device drivers usually handle the lower two layers of the OSI model,
that is the physical layer and the data
-
link layer. A network device
that is the physical layer and the data
-
link layer. A network device itself
itself natively handles the physical layer issues: It represents the
natively handles the physical layer issues: It represents the hardware to
hardware to connect to the medium and to send and receive data in the
connect to the medium and to send and receive data in the way, the physical
way, the physical layer protocol describes. The network device driver
layer protocol describes. The network device driver is responsible for getting
is responsible for getting data from the kernel's networking stack and
data from the kernel's networking stack and forwarding it to the hardware,
forwarding it to the hardware, that does the physical transmission.
that does the physical transmission. If data is received by the hardware
If data is received by the hardware respectively, the driver is
respectively, the driver is notified
(
usually by means of an interrupt
)
and
notified
(
usually by means of an interrupt
)
and has to read the data
has to read the data from the hardware memory and forward it to the network
from the hardware memory and forward it to the network stack. There
stack. There are a few more tasks, a network device driver has to handle,
are a few more tasks, a network device driver has to handle, including
including queue control, statistics and device dependent features.
queue control, statistics and device dependent features.
\paragraph
{
Driver Startup
}
\paragraph
{
Driver Startup
}
...
@@ -767,98 +768,95 @@ callback is mandatory, but for reasonable operation the ones below are
...
@@ -767,98 +768,95 @@ callback is mandatory, but for reasonable operation the ones below are
needed in any case:
needed in any case:
\begin
{
description
}
\begin
{
description
}
\item
[
int
(*
open
)(
struct net
\_
device
*)]
This function is called when
network communication has to be started, for example after a command
\item
[
open
()]
This function is called when network communication has to be
\textit
{
ifconfig ethX up
}
from user
space. Frame reception has to be
started, for example after a command
\textit
{
ifconfig ethX up
}
from user
enabled by the driver.
space. Frame reception has to be
enabled by the driver.
\item
[
int
(*
stop
)(
struct net
\_
device
*)]
The purpose of this callback
is to ``close'' the device, i.~e.
make the hardware stop receiving
\item
[
stop
()]
The purpose of this callback
is to ``close'' the device, i.~e.
frames.
make the hardware stop receiving
frames.
\item
[
int
(*
hard
\_
start
\_
xmit
)(
struct sk
\_
buff
*
, struct net
\_
device
*
)]
This function is cal
\-
led for each frame that has
to be
\item
[
hard
\_
start
\_
xmit
(
)]
This function is cal
\-
led for each frame that has
transmitted.
The network stack passes the frame as a pointer to an
to be
transmitted. The network stack passes the frame as a pointer to an
\textit
{
sk
\_
buff
}
structure
(
``socket buffer''
\index
{
Socket buffer
}
,
\textit
{
sk
\_
buff
}
structure
(
``socket buffer''
\index
{
Socket buffer
}
,
see
see
below
)
, which has to be freed after sending.
below
)
, which has to be freed after sending.
\item
[
struct net
\_
device
\_
stats
*(*
get
\_
stats
)(
struct net
\_
device
*)]
This call has to return a pointer to the device's
\item
[
get
\_
stats
()]
This call has to return a pointer to the device's
\textit
{
net
\_
device
\_
stats
}
structure, which permanently has to be
\textit
{
net
\_
device
\_
stats
}
structure, which permanently has to be
filled with
filled with
frame statistics. This means, that every time a frame is
frame statistics. This means, that every time a frame is
received, sent, or an
received, sent, or an
error happened, the appropriate counter in
error happened, the appropriate counter in
this structure has to be increased.
this structure has to be increased.
\end
{
description
}
\end
{
description
}
The actual registration is done with the
\
textit
{
register
\
_
netdev
()
}
The actual registration is done with the
\
lstinline
+
register
_
netdev
()
+
call,
call,
unregistering is done with
\
textit
{
unregister
\
_
netdev
()
}
.
unregistering is done with
\
lstinline
+
unregister
_
netdev
()
+
.
\paragraph
{
The netif Interface
}
\paragraph
{
The netif Interface
}
\index
{
netif
}
\index
{
netif
}
All other communication in the direction interface
$
\to
$
network stack is done
All other communication in the direction interface
$
\to
$
network stack is done
via the
\textit
{
netif
\_
*
}
calls. For example, on successful device opening, the
via the
\lstinline
+
netif
_
*()+
calls. For example, on successful device
network stack has to be notified, that it can now pass frames to the interface.
opening, the network stack has to be notified, that it can now pass frames to
This is done by calling
\textit
{
netif
\_
start
\_
queue
()
}
. After this call, the
the interface. This is done by calling
\lstinline
+
netif
_
start
_
queue
()+
. After
\textit
{
hard
\_
start
\_
xmit
()
}
callback can be called by the network stack.
this call, the
\lstinline
+
hard
_
start
_
xmit
()+
callback can be called by the
Furthermore a network driver usually manages a frame transmission queue. If
network stack. Furthermore a network driver usually manages a frame
this gets filled up, the network stack has to be told to stop passing further
transmission queue. If this gets filled up, the network stack has to be told
frames for a while. This happens with a call to
\textit
{
netif
\_
stop
\_
queue
()
}
.
to stop passing further frames for a while. This happens with a call to
If some frames have been sent, and there is enough space again to queue new
\lstinline
+
netif
_
stop
_
queue
()+
. If some frames have been sent, and there is
frames, this can be notified with
\textit
{
netif
\_
wake
\_
queue
()
}
. Another
enough space again to queue new frames, this can be notified with
important call is
\textit
{
netif
\_
receive
\_
skb
()
}
\footnote
{
This function is part
\lstinline
+
netif
_
wake
_
queue
()+
. Another important call is
of the NAPI
(
``New API''
)
, that replaces the ``old'' kernel
2
.
4
technique for
\lstinline
+
netif
_
receive
_
skb
()+
\footnote
{
This function is part of the NAPI
interfacing to the network stack
(
with
\textit
{
netif
\_
rx
()
}
)
. NAPI is a
(
``New API''
)
, that replaces the kernel
2
.
4
technique for interfacing to the
technique to improve network performance on Linux. Read more in
network stack
(
with
\lstinline
+
netif
_
rx
()+)
. NAPI is a technique to improve
\url
{
http:
//
www.cyberus.ca
/
~hadi
/
usenix
-
paper.tgz
}}
: It passes a frame to the
network performance on Linux. Read more in
network stack, that was just received by the device. Frame data has to be
\url
{
http:
//
www.cyberus.ca
/
~hadi
/
usenix
-
paper.tgz
}
.
}
: It passes a frame to the
network stack, that was just received by the device. Frame data has to be
packed into a so
-
called ``socket buffer'' for that
(
see below
)
.
packed into a so
-
called ``socket buffer'' for that
(
see below
)
.
\paragraph
{
Socket Buffers
}
\paragraph
{
Socket Buffers
}
\index
{
Socket buffer
}
\index
{
Socket buffer
}
Socket buffers are the basic data type for the whole network stack.
Socket buffers are the basic data type for the whole network stack. They
They serve as containers for network data and are able to quickly add
serve as containers for network data and are able to quickly add data headers
data headers and footers, or strip them off again. Therefore a socket
and footers, or strip them off again. Therefore a socket buffer consists of an
buffer consists of an allocated buffer and several pointers that mark
allocated buffer and several pointers that mark beginning of the buffer
beginning of the buffer
(
\textit
{
head
}
)
, beginning of data
(
\textit
{
head
}
)
, beginning of data
(
\textit
{
data
}
)
, end of data
(
\textit
{
data
}
)
, end of data
(
\textit
{
tail
}
)
and end of buffer
(
\textit
{
tail
}
)
and end of buffer
(
\textit
{
end
}
)
. In addition, a socket buffer
(
\textit
{
end
}
)
. In addition, a socket buffer holds network header
holds network header information and
(
in case of received data
)
a pointer to
information and
(
in case of received data
)
a pointer to the
the
\textit
{
net
\_
device
}
, it was received on. There exist functions that
\textit
{
net
\_
device
}
, it was received on. There exist functions that
create a socket buffer
(
\lstinline
+
dev
_
alloc
_
skb
()+)
, add data either from
create a socket buffer
(
\textit
{
dev
\_
alloc
\_
skb
()
}
)
, add data either
front
(
\lstinline
+
skb
_
push
()+)
or back
(
\lstinline
+
skb
_
put
()+)
, remove data
from front
(
\textit
{
skb
\_
push
()
}
)
or back
(
\textit
{
skb
\_
put
()
}
)
,
from front
(
\lstinline
+
skb
_
pull
()+)
or back
(
\lstinline
+
skb
_
trim
()+)
, or
remove data from front
(
\textit
{
skb
\_
pull
()
}
)
or back
delete the buffer
(
\lstinline
+
kfree
_
skb
()+)
. A socket buffer is passed from
(
\textit
{
skb
\_
trim
()
}
)
, or delete the buffer
(
\textit
{
kfree
\_
skb
()
}
)
.
layer to layer, and is freed by the layer that uses it the last time. In case
A socket buffer is passed from layer to layer, and is freed by the
of sending, freeing has to be done by the network driver.
layer that uses it the last time. In case of sending, freeing has to
be done by the network driver.
%------------------------------------------------------------------------------
%------------------------------------------------------------------------------
\section
{
EtherCAT Device Drivers
}
\section
{
EtherCAT Device Drivers
}
\label
{
sec:requirements
}
\label
{
sec:requirements
}
There are a few requirements for Ethernet network devices to function
There are a few requirements for Ethernet network devices to function
as
as
EtherCAT devices, when connected to an EtherCAT bus.
EtherCAT devices, when connected to an EtherCAT bus.
\paragraph
{
Dedicated Interfaces
}
\paragraph
{
Dedicated Interfaces
}
For performance and realtime purposes, the EtherCAT master needs
For performance and realtime purposes, the EtherCAT master needs direct and
direct and exclusive access to the Ethernet hardware. This implies
exclusive access to the Ethernet hardware. This implies that the network
that the network device must not be connected to the kernel's network
device must not be connected to the kernel's network stack as usual, because
stack as usual, because the kernel would try to use it as an ordinary
the kernel would try to use it as an ordinary Ethernet device.
Ethernet device.
\paragraph
{
Interrupt
-
less Operation
}
\paragraph
{
Interrupt
-
less Operation
}
\index
{
Interrupt
}
\index
{
Interrupt
}
EtherCAT frames travel through the logical EtherCAT ring and are then
EtherCAT frames travel through the logical EtherCAT ring and are then sent
sent back to the master. Communication is highly deterministic: A
back to the master. Communication is highly deterministic: A frame is sent and
frame is sent and will be received again after a constant time.
will be received again after a constant time. Therefore, there is no need to
Therefore, there is no need to notify the driver about frame
notify the driver about frame reception: The master can instead query the
reception: The master can instead query the hardware for received
hardware for received frames.
frames.
Figure~
\ref
{
fig:interrupt
}
shows two workflows for cyclic frame
Figure~
\ref
{
fig:interrupt
}
shows two workflows for cyclic frame
transmission
transmission
and reception with and without interrupts.
and reception with and without interrupts.
\begin
{
figure
}
[
htbp
]
\begin
{
figure
}
[
htbp
]
\centering
\centering
...
@@ -867,46 +865,42 @@ transmission and reception with and without interrupts.
...
@@ -867,46 +865,42 @@ transmission and reception with and without interrupts.
\label
{
fig:interrupt
}
\label
{
fig:interrupt
}
\end
{
figure
}
\end
{
figure
}
In the left workflow ``Interrupt Operation'', the data from the last
In the left workflow ``Interrupt Operation'', the data from the last cycle is
cycle is first processed and a new frame is assembled with new
first processed and a new frame is assembled with new datagrams, which is then
datagrams, which is then sent. The cyclic work is done for now.
sent. The cyclic work is done for now. Later, when the frame is received
Later, when the frame is received again by the hardware, an interrupt
again by the hardware, an interrupt is triggered and the ISR is executed. The
is triggered and the ISR is executed. The ISR will fetch the frame
ISR will fetch the frame data from the hardware and initiate the frame
data from the hardware and initiate the frame dissection: The
dissection: The datagrams will be processed, so that the data is ready for
datagrams will be processed, so that the data is ready for processing
processing in the next cycle.
in the next cycle.
In the right workflow ``Interrupt
-
less Operation'', there is no hardware
In the right workflow ``Interrupt
-
less Operation'', there is no
interrupt enabled. Instead, the hardware will be polled by the master by
hardware interrupt enabled. Instead, the hardware will be polled by
executing the ISR. If the frame has been received in the meantime, it will be
the master by executing the ISR. If the frame has been received in the
dissected. The situation is now the same as at the beginning of the left
meantime, it will be dissected. The situation is now the same as at
workflow: The received data is processed and a new frame is assembled and
the beginning of the left workflow: The received data is processed and
sent. There is nothing to do for the rest of the cycle.
a new frame is assembled and sent. There is nothing to do for the rest
of the cycle.
The interrupt
-
less operation is desirable, because there is simply no need for
an interrupt. Moreover hardware interrupts are not conducive in improving the
The interrupt
-
less operation is desirable, because there is simply no
driver's realtime behaviour: Their indeterministic incidences contribute to
need for an interrupt. Moreover hardware interrupts are not conducive
increasing the jitter. Besides, if a realtime extension
(
like RTAI
)
is used,
in improving the driver's realtime behaviour: Their indeterministic
some additional effort would have to be made to prioritize interrupts.
incidences contribute to increasing the jitter. Besides, if a realtime
extension
(
like RTAI
)
is used, some additional effort would have to be
made to prioritize interrupts.
\paragraph
{
Ethernet and EtherCAT Devices
}
\paragraph
{
Ethernet and EtherCAT Devices
}
Another issue lies in the way Linux handles devices of the same type.
Another issue lies in the way Linux handles devices of the same type. For
For example, a PCI
\nomenclature
{
PCI
}{
Peripheral Component
example, a PCI
\nomenclature
{
PCI
}{
Peripheral Component Interconnect, Computer
Interconnect, Computer Bus
}
driver scans the PCI bus for devices it
Bus
}
driver scans the PCI bus for devices it can handle. Then it registers
can handle. Then it registers itself as the responsible driver for all
itself as the responsible driver for all of the devices found. The problem is,
of the devices found. The problem is, that an unmodified driver can
that an unmodified driver can not be told to ignore a device because it will
not be told to ignore a device because it will be used for EtherCAT
be used for EtherCAT later. There must be a way to handle multiple devices of
later. There must be a way to handle multiple devices of the same
the same type, where one is reserved for EtherCAT, while the other is treated
type, where one is reserved for EtherCAT, while the other is treated
as an ordinary Ethernet device.
as an ordinary Ethernet device.
For all this reasons, the author
has
decided that the only acceptable
For all this reasons, the author decided that the only acceptable
solution is
solution is
to modify standard Ethernet drivers in a way that they
to modify standard Ethernet drivers in a way that they
keep their normal
keep their normal
functionality, but gain the ability to treat one or
functionality, but gain the ability to treat one or
more of the devices as
more of the devices as
EtherCAT
-
capable.
EtherCAT
-
capable.
Below are the advantages of this solution:
Below are the advantages of this solution:
...
@@ -1921,10 +1915,9 @@ $\rightarrow$~READ STATES
...
@@ -1921,10 +1915,9 @@ $\rightarrow$~READ STATES
for the first slave marked as offline.
for the first slave marked as offline.
$
\rightarrow
$
~REWRITE ADDRESSES
$
\rightarrow
$
~REWRITE ADDRESSES
\item
[
REWRITE ADDRESSES
]
If the station address was successfully
\item
[
REWRITE ADDRESSES
]
If the station address was successfully written, it is
written, it is sear
\-
ched for the next slave marked as offline. If
searched for the next slave marked as offline. If there is one, its address is
there is one, its address is reconfigured, too.
reconfigured, too.
$
\rightarrow
$
~REWRITE ADDRESSES
$
\rightarrow
$
~REWRITE ADDRESSES
If there are no more slaves marked as offline, the state machine is
If there are no more slaves marked as offline, the state machine is
restarted.
$
\rightarrow
$
~START
restarted.
$
\rightarrow
$
~START
...
@@ -2428,7 +2421,7 @@ approach was considered as difficult, because of several reasons:
...
@@ -2428,7 +2421,7 @@ approach was considered as difficult, because of several reasons:
the instances using the network interfaces.
the instances using the network interfaces.
\end
{
itemize
}
\end
{
itemize
}
\paragraph
{
Number of Handlers
}
\paragraph
{
Number of Handlers
}
% FIXME
The master module has a parameter
\textit
{
ec
\_
eoeif
\_
count
}
to specify
The master module has a parameter
\textit
{
ec
\_
eoeif
\_
count
}
to specify
the number of EoE interfaces
(
and handlers
)
per master to create. This
the number of EoE interfaces
(
and handlers
)
per master to create. This
...
@@ -3099,7 +3092,7 @@ extracted from the Linux kernel sources.
...
@@ -3099,7 +3092,7 @@ extracted from the Linux kernel sources.
The source code is documented using Doxygen~
\cite
{
doxygen
}
. To build the HTML
The source code is documented using Doxygen~
\cite
{
doxygen
}
. To build the HTML
documentation, you must have the Doxygen software installed. The below command
documentation, you must have the Doxygen software installed. The below command
will generate the documents in the subdirecory
\textit
{
doxygen-output
}
:
will generate the documents in the subdirec
t
ory
\textit
{
doxygen-output
}
:
\begin{lstlisting}
\begin{lstlisting}
$
`
\textbf
{
make doc
}
`
$
`
\textbf
{
make doc
}
`
...
@@ -3119,9 +3112,9 @@ sysconfig file and the user space tools to the prefix path.
...
@@ -3119,9 +3112,9 @@ sysconfig file and the user space tools to the prefix path.
# `
\textbf
{
make install
}
`
# `
\textbf
{
make install
}
`
\end
{
lstlisting
}
\end
{
lstlisting
}
If the target kernel's modules directory is not under
If the target kernel's modules directory is not under
\textit
{
/
lib
/
modules
}
, a
\textit
{
/
lib
/
modules
}
, a
different destination directory can be
different destination directory can be
specified with the
\lstinline
+
DESTDIR
+
specified with the
\textit
{
DESTDIR
}
make variable. For example:
make variable. For example:
\begin
{
lstlisting
}
\begin
{
lstlisting
}
# `
\textbf
{
make DESTDIR
=/
vol
/
nfs
/
root modules
\_
install
}
`
# `
\textbf
{
make DESTDIR
=/
vol
/
nfs
/
root modules
\_
install
}
`
...
@@ -3824,10 +3817,10 @@ for rapid realtime code generation under Linux with Simulink/RTW and EtherCAT
...
@@ -3824,10 +3817,10 @@ for rapid realtime code generation under Linux with Simulink/RTW and EtherCAT
technology.
\url
{
http:
//
etherlab.org
/
en
}
,
2008
.
technology.
\url
{
http:
//
etherlab.org
/
en
}
,
2008
.
\bibitem
{
dlspec
}
IEC
61158
-
4
-
12
: Data
-
link Protocol Specification.
\bibitem
{
dlspec
}
IEC
61158
-
4
-
12
: Data
-
link Protocol Specification.
International Electrotechnical Comission
(
IEC
)
,
2005
.
International Electrotechnical Com
m
ission
(
IEC
)
,
2005
.
\bibitem
{
alspec
}
IEC
61158
-
6
-
12
: Application Layer Protocol Specification.
\bibitem
{
alspec
}
IEC
61158
-
6
-
12
: Application Layer Protocol Specification.
International Electrotechnical Comission
(
IEC
)
,
2005
.
International Electrotechnical Com
m
ission
(
IEC
)
,
2005
.
\bibitem
{
gpl
}
GNU General Public License, Version
2
.
\bibitem
{
gpl
}
GNU General Public License, Version
2
.
\url
{
http:
//
www.gnu.org
/
licenses
/
gpl.txt
}
. August~
9
,
2006
.
\url
{
http:
//
www.gnu.org
/
licenses
/
gpl.txt
}
. August~
9
,
2006
.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment