Skip to contentSkip to conversation

Class driver for raw Ethernet packets

RFC In review Richard Cochran 4 participants 21 messages Sep 23, 2011 – Sep 28, 2011

lore
Share & tools
lore
#0 lore raw

cover Class driver for raw Ethernet packets

This patch adds a class driver for raw Ethernet drivers under Xenomai. The goal is to support industrial protocols such as EtherCAT and IEC 61850, where the "stack" is a user space program needing direct access at the packet level. The class driver offers interfaces for registration, buffer management, and packet sending/receiving.

Although this patch is a kind of first draft, still I have it working on the Freescale P2020 with a real world application, with very good results. I can post a patch series for the gianfar driver in the ipipe tree, if anyone is interested.

The user space interface is a character device and not a socket, simply because my applications will probably never need fancy socket options. The class driver could surely be made to offer a socket instead, but I think the character is sufficient.

The class driver is clearly in the wrong directory within the source tree, but I put it there just to get started. It really does not fit to any of the other drivers, so it probably would need its own place under ksrc/drivers.

Thanks in advance for your comments,

Richard

Richard Cochran (1):
Add a class driver for raw Ethernet packets.

 include/rtdm/rtpacket.h       |   99 ++++++++++++
 ksrc/drivers/testing/Kconfig  |    8 +
 ksrc/drivers/testing/Makefile |    3 +
 ksrc/drivers/testing/packet.c |  352 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 462 insertions(+), 0 deletions(-)
 create mode 100644 include/rtdm/rtpacket.h
 create mode 100644 ksrc/drivers/testing/packet.c
Signature · 1 line
1.7.2.5
#1 lore raw

RFC 1/1 Add a class driver for raw Ethernet packets.

This patch adds a class driver for sending and receiving raw Ethernet packets over a character device interface.

---
 include/rtdm/rtpacket.h       |   99 ++++++++++++
 ksrc/drivers/testing/Kconfig  |    8 +
 ksrc/drivers/testing/Makefile |    3 +
 ksrc/drivers/testing/packet.c |  352 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 462 insertions(+), 0 deletions(-)
 create mode 100644 include/rtdm/rtpacket.h
 create mode 100644 ksrc/drivers/testing/packet.c
include/rtdm/rtpacket.h new file +99 -0
new file mode 100644
index 0000000..87930de
@@ -0,0 +1,99 @@
+/*
+ * Xenomai Packet Interface - class driver for raw Ethernet packets
+ *
+ * Copyright (C) 2011 OMICRON electronics GmbH
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef _RTPACKET_H
+#define _RTPACKET_H
+
+#include <rtdm/rtdm.h>
+
+#define RTPACKET_MAX_FILTER	16
+
+struct rtpacket_filter {
+	__u16 ethertype[RTPACKET_MAX_FILTER];
+};
+
+#define RTPACKET_FILTER _IOW(RTDM_CLASS_TESTING, 0x80, struct rtpacket_filter)
+
+#ifdef __KERNEL__
+
+#include <linux/list.h>
+#include <rtdm/rtdm_driver.h>
+
+#define RTPACKET_TX_POOL_SIZE	128
+#define RTPACKET_BUFFER_SIZE	1536
+
+struct rtp_addr {
+	void *va;
+	dma_addr_t pa;
+};
+
+struct rtpacket {
+	struct list_head list;
+	struct rtp_addr base;
+	struct rtp_addr data;
+	int length;
+};
+
+struct rtpacket_pool {
+	struct list_head list;
+	rtdm_lock_t lock;
+	struct rtpacket *pkt;
+	unsigned int npkt;
+	unsigned int pktsize;
+	struct device *dev;
+};
+
+struct rtpacket_driver_ops {
+	struct module *owner;
+	char name[16];
+	int (*filter)(struct rtpacket_driver_ops *p, struct rtpacket_filter *f);
+	int (*transmit)(struct rtpacket_driver_ops *ops, struct rtpacket *rtp);
+	void (*recycle)(struct rtpacket_driver_ops *ops, struct rtpacket *rtp);
+};
+
+struct rtpacket_interface;
+
+/* packet pool methods */
+
+void rtpacket_pool_drain(struct rtpacket_pool *p);
+
+int rtpacket_pool_init(struct rtpacket_pool *p, struct device *dev,
+		       unsigned int reserved,
+		       unsigned int npkt, unsigned int bufsize);
+
+struct rtpacket *rtpacket_pool_pop(struct rtpacket_pool *p);
+
+void rtpacket_pool_push(struct rtpacket_pool *p, struct rtpacket *rtp);
+
+/* registration methods */
+
+void rtpacket_deregister(struct rtpacket_interface *iface);
+
+struct rtpacket_interface *rtpacket_register(struct rtpacket_driver_ops *ops,
+					     struct device *dev,
+					     unsigned int tx_reserved);
+
+/* receive and transmit path methods */
+
+int rtpacket_receive(struct rtpacket_interface *iface, struct rtpacket *rtp);
+
+void rtpacket_recycle(struct rtpacket_interface *iface, struct rtpacket *rtp);
+
+#endif /* __KERNEL__ */
+#endif
ksrc/drivers/testing/Kconfig +8 -0
index 28504dc..6f67e7c 100644
@@ -9,6 +9,14 @@ config XENO_DRIVERS_TESTING_LEGACY_NAMES
 	Only enable this if you plan to use old userspace tools with the
 	drivers.
 
+config XENO_DRIVERS_PACKET
+	depends on XENO_SKIN_RTDM
+	tristate "Raw Ethernet packet driver"
+	default y
+	help
+	Provides a class driver for sending and receiving raw Ethernet
+	packets over a simple character device interface.
+
 config XENO_DRIVERS_TIMERBENCH
 	depends on XENO_SKIN_RTDM
 	tristate "Timer benchmark driver"
ksrc/drivers/testing/Makefile +3 -0
index 17a6cf1..78679c8 100644
@@ -4,6 +4,7 @@ ifeq ($(PATCHLEVEL),6)
 
 EXTRA_CFLAGS += -D__IN_XENOMAI__ -Iinclude/xenomai
 
+obj-$(CONFIG_XENO_DRIVERS_PACKET)     += xeno_packet.o
 obj-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += xeno_timerbench.o
 obj-$(CONFIG_XENO_DRIVERS_IRQBENCH)   += xeno_irqbench.o
 obj-$(CONFIG_XENO_DRIVERS_SWITCHTEST) += xeno_switchtest.o
@@ -11,6 +12,8 @@ obj-$(CONFIG_XENO_DRIVERS_KLATENCY)   += xeno_klat.o
 obj-$(CONFIG_XENO_DRIVERS_SIGTEST)    += xeno_sigtest.o
 obj-$(CONFIG_XENO_DRIVERS_RTDMTEST)   += xeno_rtdmtest.o
 
+xeno_packet-y := packet.o
+
 xeno_timerbench-y := timerbench.o
 
 xeno_irqbench-y := irqbench.o
ksrc/drivers/testing/packet.c new file +352 -0

352 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#3 lore raw
In reply to Richard Cochran
Quoted 16 lines · On Friday 23 September 2011 13:02:19 Richard Cochran wrote:

This patch adds a class driver for raw Ethernet drivers under Xenomai. The goal is to support industrial protocols such as EtherCAT and IEC 61850, where the "stack" is a user space program needing direct access at the packet level. The class driver offers interfaces for registration, buffer management, and packet sending/receiving.

Although this patch is a kind of first draft, still I have it working on the Freescale P2020 with a real world application, with very good results. I can post a patch series for the gianfar driver in the ipipe tree, if anyone is interested.

The user space interface is a character device and not a socket, simply because my applications will probably never need fancy socket options. The class driver could surely be made to offer a socket instead, but I think the character is sufficient.

Quoted 6 lines

The class driver is clearly in the wrong directory within the source tree, but I put it there just to get started. It really does not fit to any of the other drivers, so it probably would need its own place under ksrc/drivers.

Thanks in advance for your comments,

How does this relate to rtnet, i.e. why didn't you write an rtnet driver ?

Peter

#4 lore raw
In reply to Richard Cochran
Quoted 11 lines · Richard Cochran

This patch adds a class driver for raw Ethernet drivers under Xenomai. The goal is to support industrial protocols such as EtherCAT and IEC 61850, where the "stack" is a user space program needing direct access at the packet level. The class driver offers interfaces for registration, buffer management, and packet sending/receiving.

Although this patch is a kind of first draft, still I have it working on the Freescale P2020 with a real world application, with very good results. I can post a patch series for the gianfar driver in the ipipe tree, if anyone is interested.

Quoted 4 lines

The user space interface is a character device and not a socket, simply because my applications will probably never need fancy socket options. The class driver could surely be made to offer a socket instead, but I think the character is sufficient.

Many interesting interfaces already exists for standard PF_PACKET (e.g. time stamping), plus you gain portability this way. So let's not create something special here even if it's sufficient for the first use case.

Quoted 5 lines

The class driver is clearly in the wrong directory within the source tree, but I put it there just to get started. It really does not fit to any of the other drivers, so it probably would need its own place under ksrc/drivers.

New class, new directory.

However, the key question is how this approach relates to RTnet. Right now its likely comparing apples to onions, but that may change as things evolve in the right direction.

Can you explain a bit about your NIC driver architecture and the maintenance strategy? It looks like you are taking an approach of patching existing drivers in-tree. Anything that resolves the maintenance pain we have with the RTnet model is already worth considering. Did you take this approach intentionally? What pros and cons do you see?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#5 lore raw
Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Richard Cochran

This patch adds a class driver for raw Ethernet drivers under Xenomai. The goal is to support industrial protocols such as EtherCAT and IEC 61850, where the "stack" is a user space program needing direct access at the packet level. The class driver offers interfaces for registration, buffer management, and packet sending/receiving.

Although this patch is a kind of first draft, still I have it working on the Freescale P2020 with a real world application, with very good results. I can post a patch series for the gianfar driver in the ipipe tree, if anyone is interested.

Quoted 8 lines
Quoted 4 lines

The user space interface is a character device and not a socket, simply because my applications will probably never need fancy socket options. The class driver could surely be made to offer a socket instead, but I think the character is sufficient.

Many interesting interfaces already exists for standard PF_PACKET (e.g. time stamping), plus you gain portability this way. So let's not create something special here even if it's sufficient for the first use case.

Okay, so if the raw packet driver idea finds acceptance (outside of rtnet), then I am willing to recast the thing as a socket.

Quoted 8 lines
Quoted 5 lines

The class driver is clearly in the wrong directory within the source tree, but I put it there just to get started. It really does not fit to any of the other drivers, so it probably would need its own place under ksrc/drivers.

New class, new directory.

Quoted 7 lines

However, the key question is how this approach relates to RTnet. Right now its likely comparing apples to onions, but that may change as things evolve in the right direction.

Can you explain a bit about your NIC driver architecture and the maintenance strategy? It looks like you are taking an approach of patching existing drivers in-tree.

Yes, that is right.

Quoted 4 lines

Anything that resolves the
maintenance pain we have with the RTnet model is already worth considering. Did you take this approach intentionally? What pros and cons do you see?

So, here is my story. Many months ago I needed a Xenomai program to send and receive raw packets. I looked at rtnet and decided that it was way too complicated. So, I added a rtdm character device to the Linux Ethernet MAC driver, a rather simple hack:

 drivers/net/arm/Makefile     |    4 +
 drivers/net/arm/ixp4xx_eth.c |  316
 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 319 insertions(+), 1 deletions(-)

That worked great. I did not bother to implement more than read/write, but I used a normal socket to set the multicast Rx list.

Now, I needed to port that application to a new platform. Again, I looked at rtnet (and the recently posted gianfar code), and again I came to the conclusion that I was better off with a direct driver hack.

Most of those 316 additional lines, above, were rtdm driver boiler plate, and I this time I wanted to abstract the code that will surely be the same, like device registration, user space send/receive, and buffer management. (Because the eTSEC (gianfar) is much more complex, and because I wanted hardware packet classification, the driver patch is much larger than before.)

I admire the rtnet project. Based on my limited understanding of it, if I really needed deterministic Ethernet, then I would write a brand new driver for the eTSEC (perhaps using gianfar.c as a reference), but I would *not* try and adapt the Linux driver.

Conversely, if I were writing a brand new driver, I would surely offer it as an rtnet driver, even thought I only need raw packets.

However, for the sole requirement of raw Ethernet, I think my simple driver API is much easier to work into existing drivers. I also think it is way easier to maintain by rebasing on later changes.

IMHO, the pros of my approach are:

- Simple to implement new drivers.

Compare my rtpacket.h with the rtnet driver headers to see what I mean. Or, read rtnet/Documentation/README.drvporting and ask yourself, is it easy to port a driver to rtnet?

- Easier to maintain drivers.

Making regular drivers into real time drivers will always be a chore. But, with its simple interface, the packet class driver hack is way less painful. (Look at my gianfar example. There really are not many changes to the Linux driver.)

- Better integration with Xenomai.

This class driver is simple enough to ship with Xenomai. It would be nice to offer raw Ethernet to users directly, not make them jump through addition hoops. For example, the last time I tried to compile the latest rtnet from git (few months ago) I got:

checking for Xenomai version... configure: error:
*** Unsupported Xenomai version 2.5.6 in home/cochran/stage/usr/xenomai

I really don't know how many people would need such an interface (and not need rtnet), but I would imagine that a need exists.

Thanks,

Richard

#6 lore raw
Quoted 85 lines · Richard Cochran
Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Richard Cochran

This patch adds a class driver for raw Ethernet drivers under Xenomai. The goal is to support industrial protocols such as EtherCAT and IEC 61850, where the "stack" is a user space program needing direct access at the packet level. The class driver offers interfaces for registration, buffer management, and packet sending/receiving.

Although this patch is a kind of first draft, still I have it working on the Freescale P2020 with a real world application, with very good results. I can post a patch series for the gianfar driver in the ipipe tree, if anyone is interested.

Quoted 8 lines
Quoted 4 lines

The user space interface is a character device and not a socket, simply because my applications will probably never need fancy socket options. The class driver could surely be made to offer a socket instead, but I think the character is sufficient.

Many interesting interfaces already exists for standard PF_PACKET (e.g. time stamping), plus you gain portability this way. So let's not create something special here even if it's sufficient for the first use case.

Okay, so if the raw packet driver idea finds acceptance (outside of rtnet), then I am willing to recast the thing as a socket.

Quoted 8 lines
Quoted 5 lines

The class driver is clearly in the wrong directory within the source tree, but I put it there just to get started. It really does not fit to any of the other drivers, so it probably would need its own place under ksrc/drivers.

New class, new directory.

Quoted 7 lines

However, the key question is how this approach relates to RTnet. Right now its likely comparing apples to onions, but that may change as things evolve in the right direction.

Can you explain a bit about your NIC driver architecture and the maintenance strategy? It looks like you are taking an approach of patching existing drivers in-tree.

Yes, that is right.

Quoted 4 lines

Anything that resolves the
maintenance pain we have with the RTnet model is already worth considering. Did you take this approach intentionally? What pros and cons do you see?

So, here is my story. Many months ago I needed a Xenomai program to send and receive raw packets. I looked at rtnet and decided that it was way too complicated. So, I added a rtdm character device to the Linux Ethernet MAC driver, a rather simple hack:

 drivers/net/arm/Makefile     |    4 +
 drivers/net/arm/ixp4xx_eth.c |  316
 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 319 insertions(+), 1 deletions(-)

That worked great. I did not bother to implement more than read/write, but I used a normal socket to set the multicast Rx list.

Now, I needed to port that application to a new platform. Again, I looked at rtnet (and the recently posted gianfar code), and again I came to the conclusion that I was better off with a direct driver hack.

Most of those 316 additional lines, above, were rtdm driver boiler plate, and I this time I wanted to abstract the code that will surely be the same, like device registration, user space send/receive, and buffer management. (Because the eTSEC (gianfar) is much more complex, and because I wanted hardware packet classification, the driver patch is much larger than before.)

I admire the rtnet project. Based on my limited understanding of it, if I really needed deterministic Ethernet, then I would write a brand new driver for the eTSEC (perhaps using gianfar.c as a reference), but I would *not* try and adapt the Linux driver.

Conversely, if I were writing a brand new driver, I would surely offer it as an rtnet driver, even thought I only need raw packets.

However, for the sole requirement of raw Ethernet, I think my simple driver API is much easier to work into existing drivers. I also think it is way easier to maintain by rebasing on later changes.

Quoted 7 lines

IMHO, the pros of my approach are:

- Simple to implement new drivers.

Compare my rtpacket.h with the rtnet driver headers to see what I mean. Or, read rtnet/Documentation/README.drvporting and ask yourself, is it easy to port a driver to rtnet?

I would be careful with deriving generic properties from a potentially lucky first example. Already tried to apply your pattern on a standard PCI NIC, e.g. the common Intel 8257x series?

Quoted 7 lines

- Easier to maintain drivers.

Making regular drivers into real time drivers will always be a chore. But, with its simple interface, the packet class driver hack is way less painful. (Look at my gianfar example. There really are not many changes to the Linux driver.)

What is your "simple interface"? That's what I'm interested in. What is the pattern to apply on an arbitrary driver to add RT support? How does interface claiming work (so the RT is not conflicting with Linux)? How does the configuration work? How do you deal with things like watchdogs, error handling, IRQ coalescing avoidance, etc.? Hmm, looks like your concept is completely lacking IRQ support. That's of course a major limitation, specifically with RT Ethernet protocols where the network provides a clock source.

Quoted 8 lines

- Better integration with Xenomai.

This class driver is simple enough to ship with Xenomai. It would be nice to offer raw Ethernet to users directly, not make them jump through addition hoops. For example, the last time I tried to compile the latest rtnet from git (few months ago) I got:

Quoted 5 lines

checking for Xenomai version... configure: error:
*** Unsupported Xenomai version 2.5.6 in home/cochran/stage/usr/xenomai

I really don't know how many people would need such an interface (and not need rtnet), but I would imagine that a need exists.

I'm surely not voting against Xenomai integration of some RT Ethernet (micro-)stack. I'm even not voting against rewriting the RTnet mess from scratch.

What I'm skeptic about are statements like "this is so much simpler because it will never require X or Y". Reminds me of the people reimplementing QEMU as kvm-tool. The architecture of an RT Ethernet stack should at least be based on the experience of RTnet, not widely ignore it.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#7 lore raw
Quoted 10 lines · Jan Kiszka
Quoted 5 lines · Richard Cochran

- Simple to implement new drivers.

Compare my rtpacket.h with the rtnet driver headers to see what I mean. Or, read rtnet/Documentation/README.drvporting and ask yourself, is it easy to port a driver to rtnet?

I would be careful with deriving generic properties from a potentially lucky first example. Already tried to apply your pattern on a standard PCI NIC, e.g. the common Intel 8257x series?

Of course, you are right about this. It would make sense to try a few different flavors of MAC driver. But I do think my class API makes sense from a design standpoint.

Quoted 8 lines
Quoted 6 lines

- Easier to maintain drivers.

Making regular drivers into real time drivers will always be a chore. But, with its simple interface, the packet class driver hack is way less painful. (Look at my gianfar example. There really are not many changes to the Linux driver.)

What is your "simple interface"? That's what I'm interested in.

* class driver provides:
- rtpacket_receive Called by MAC driver when a packet arrives.
- rtpacket_recycle Called by MAC driver to yield transmitted buffers back to class driver.
* MAC driver provides:
- ops.transmit Called by class driver to send a packet.
- ops.recycle Called by class driver to yield delivered buffers
back to MAC driver.
- ops.filter User space must provide a list of allowed Ether
types, and the MAC driver must filter out types not in the list.
* That's all, folks.

Quoted 2 lines

What is the pattern to apply on an arbitrary driver to add RT support?

There is no getting around the fact that you must get to know the MAC driver (and perhaps HW). How to splice the interface into the driver must be seen on a case by case basis.

Quoted 2 lines

How does interface claiming work (so the RT is not conflicting with Linux)?

The idea is to always offer both, so every ethX creates a rt-ethX. The RT traffic should always take priority over non-RT, to the extent possible in the hardware.

Quoted 1 line

How does the configuration work?

The RT port is up whenever the normal network interface is. I do *not* want to duplicate anything from the Linux network stack at all.

The only "nice-to-have" I think missing is MAC address filtering or enabling mutlicast MAC reception or promiscuous mode. Since there are global (at the hardware level), you can just set this using a normal socket. But perhaps a user API that just calls the normal Linux kernel code would work.

Quoted 2 lines

How do you deal with things like watchdogs, error handling, IRQ coalescing avoidance, etc.?

Again, every MAC driver needs to be tastefully and wisely adapted. I don't necessarily need to avoid coalescing. The goal (for me) is *not* to provide deterministic Ethernet performance. Instead the RT packets should just be delivered ASAP.

The userland RT send/recv methods must not block or switch to secondary mode, however.

Quoted 3 lines

Hmm, looks like your concept is completely lacking IRQ support. That's of course a major limitation, specifically with RT Ethernet protocols where the network provides a clock source.

I don't know of any Ethernet protocols where the network provides a clock, except for NTP and PTP, and for these RT performance is not required. (EtherCAT does not count because the clock source is in the first slave.)

Again, I know that rtnet is making Ethernet deterministic, but I just don't need this.

Quoted 3 lines

I'm surely not voting against Xenomai integration of some RT Ethernet (micro-)stack. I'm even not voting against rewriting the RTnet mess from scratch.

So, I think raw Ethernet access is not even a micro-stack. It is no stack at all, just packets. The stack logic, if any, goes into the user space program.

Quoted 5 lines

What I'm skeptic about are statements like "this is so much simpler because it will never require X or Y". Reminds me of the people reimplementing QEMU as kvm-tool. The architecture of an RT Ethernet stack should at least be based on the experience of RTnet, not widely ignore it.

no stack, no stack, no stack!

It sounds like to me that the requirements on rtnet drivers practically force you to write a special rtnet driver. I don't need rtnet, just raw Ethernet from a Xenomai program in primary mode. This is relatively easy to do by splicing into the existing MAC drivers.

Thanks,

Richard

#8 lore raw
Quoted 4 lines · Richard Cochran

Again, every MAC driver needs to be tastefully and wisely adapted. I don't necessarily need to avoid coalescing. The goal (for me) is *not* to provide deterministic Ethernet performance. Instead the RT packets should just be delivered ASAP.

This is obviously the point I completely missed. And it makes the whole thing fairly uninteresting IMHO. If you want to do Ethercat, PowerLink or Profinet (RT), you do need a certain level of determinism along the *whole* packet path. And for the latter two, you definitely need RT IRQ support, Ethercat can be OK to poll in fast setups.

Quoted 1 line

From that POV, your approach is likely OK. But I doubt its of generic

use, specifically for industrial RT Ethernet.

Jan

PS: You do have a stack, even if you don't like it: driver, packet layer, application. :)

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#9 lore raw
Quoted 6 lines · Jan Kiszka
Quoted 4 lines · Richard Cochran

Again, every MAC driver needs to be tastefully and wisely adapted. I don't necessarily need to avoid coalescing. The goal (for me) is *not* to provide deterministic Ethernet performance. Instead the RT packets should just be delivered ASAP.

Quoted 8 lines

This is obviously the point I completely missed. And it makes the whole thing fairly uninteresting IMHO. If you want to do Ethercat, PowerLink or Profinet (RT), you do need a certain level of determinism along the *whole* packet path. And for the latter two, you definitely need RT IRQ support, Ethercat can be OK to poll in fast setups.

From that POV, your approach is likely OK. But I doubt its of generic use, specifically for industrial RT Ethernet.

So, how does rtnet support EtherCAT?

Does it support PowerLink and Profinet?

Thanks,
Richard

#10 lore raw
Quoted 13 lines · Richard Cochran
Quoted 12 lines · Jan Kiszka
Quoted 4 lines · Richard Cochran

Again, every MAC driver needs to be tastefully and wisely adapted. I don't necessarily need to avoid coalescing. The goal (for me) is *not* to provide deterministic Ethernet performance. Instead the RT packets should just be delivered ASAP.

This is obviously the point I completely missed. And it makes the whole thing fairly uninteresting IMHO. If you want to do Ethercat, PowerLink or Profinet (RT), you do need a certain level of determinism along the *whole* packet path. And for the latter two, you definitely need RT IRQ support, Ethercat can be OK to poll in fast setups.

Quoted 4 lines
Quoted 2 lines

From that POV, your approach is likely OK. But I doubt its of generic use, specifically for industrial RT Ethernet.

So, how does rtnet support EtherCAT?

There was once the EtherCAT Master Library. IIRC, it was discontinued and removed from the web for non-technical reasons.

Quoted 2 lines

Does it support PowerLink and Profinet?

Not that I know, but that's not the point. You said your approach could provide the technical foundation for such a class of use cases while I doubt it would work as is.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#11 lore raw
Quoted 23 lines · Jan Kiszka
Quoted 13 lines · Richard Cochran
Quoted 12 lines · Jan Kiszka
Quoted 4 lines · Richard Cochran

Again, every MAC driver needs to be tastefully and wisely adapted. I don't necessarily need to avoid coalescing. The goal (for me) is *not* to provide deterministic Ethernet performance. Instead the RT packets should just be delivered ASAP.

This is obviously the point I completely missed. And it makes the whole thing fairly uninteresting IMHO. If you want to do Ethercat, PowerLink or Profinet (RT), you do need a certain level of determinism along the *whole* packet path. And for the latter two, you definitely need RT IRQ support, Ethercat can be OK to poll in fast setups.

Quoted 4 lines
Quoted 2 lines

From that POV, your approach is likely OK. But I doubt its of generic use, specifically for industrial RT Ethernet.

So, how does rtnet support EtherCAT?

There was once the EtherCAT Master Library. IIRC, it was discontinued and removed from the web for non-technical reasons.

Quoted 1 line
Quoted 5 lines
Quoted 1 line

Does it support PowerLink and Profinet?

Not that I know, but that's not the point. You said your approach could provide the technical foundation for such a class of use cases while I doubt it would work as is.

But that is the point. Correct me please if I am wrong, but isn't rtnet a competitor or alternative to EtherCAT, PowerLink, and Profinet?

Unless rtnet implements (or helps to implement) these, it is kind of silly to say, "your way won't work, you should use rtnet instead."

I don't know PowerLink or Profinet, but I do know EtherCAT and IEC 61850, and those two can surely be implemented on the interface that I am talking about.

Also, the interface that I propose does not preclude the use of RTDM ISR in the driver, so I wonder what exactly bothers you about it?

Thanks,
Richard

#12 lore raw
Quoted 26 lines · Richard Cochran
Quoted 25 lines · Jan Kiszka
Quoted 13 lines · Richard Cochran
Quoted 12 lines · Jan Kiszka
Quoted 4 lines · Richard Cochran

Again, every MAC driver needs to be tastefully and wisely adapted. I don't necessarily need to avoid coalescing. The goal (for me) is *not* to provide deterministic Ethernet performance. Instead the RT packets should just be delivered ASAP.

This is obviously the point I completely missed. And it makes the whole thing fairly uninteresting IMHO. If you want to do Ethercat, PowerLink or Profinet (RT), you do need a certain level of determinism along the *whole* packet path. And for the latter two, you definitely need RT IRQ support, Ethercat can be OK to poll in fast setups.

Quoted 4 lines
Quoted 2 lines

From that POV, your approach is likely OK. But I doubt its of generic use, specifically for industrial RT Ethernet.

So, how does rtnet support EtherCAT?

There was once the EtherCAT Master Library. IIRC, it was discontinued and removed from the web for non-technical reasons.

Quoted 2 lines

Does it support PowerLink and Profinet?

Quoted 7 lines
Quoted 3 lines

Not that I know, but that's not the point. You said your approach could provide the technical foundation for such a class of use cases while I doubt it would work as is.

But that is the point. Correct me please if I am wrong, but isn't rtnet a competitor or alternative to EtherCAT, PowerLink, and Profinet?

That's a common misunderstanding: RTnet is a networking stack with many _optional_ components (like RTmac, RTcfg etc.). I would bet that it's more frequently used today in minimal setups, i.e. just the core, some driver, and either PF_PACKET or UDP/IP.

Quoted 7 lines

Unless rtnet implements (or helps to implement) these, it is kind of silly to say, "your way won't work, you should use rtnet instead."

I don't know PowerLink or Profinet, but I do know EtherCAT and IEC 61850, and those two can surely be implemented on the interface that I am talking about.

It works, but it won't give you a deterministic control loop as you still have Linux in the game.

Quoted 3 lines

Also, the interface that I propose does not preclude the use of RTDM ISR in the driver, so I wonder what exactly bothers you about it?

That you claim it's simpler based on lacking features - like RT IRQ support and the associated proper driver integration of that. Maybe it turns out to be simpler, but that is by far proven yet.

I was simply hoping to collect some new ideas how to address the driver maintenance issue in a better way but without dropping key features needed for RT networking. Something like "let's add generic RT channels to Linux upstream drivers and then only patch them fit RTDM". Not sure if that works, but it would come with a vision how to keep things more maintainable.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#13 lore raw
Quoted 6 lines · Jan Kiszka

I was simply hoping to collect some new ideas how to address the driver maintenance issue in a better way but without dropping key features needed for RT networking. Something like "let's add generic RT channels to Linux upstream drivers and then only patch them fit RTDM". Not sure if that works, but it would come with a vision how to keep things more maintainable.

+this could be useful for other scenarios - on PREEMPT-RT.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#14 lore raw
Quoted 9 lines · Jan Kiszka
Quoted 6 lines · Jan Kiszka

I was simply hoping to collect some new ideas how to address the driver maintenance issue in a better way but without dropping key features needed for RT networking. Something like "let's add generic RT channels to Linux upstream drivers and then only patch them fit RTDM". Not sure if that works, but it would come with a vision how to keep things more maintainable.

+this could be useful for other scenarios - on PREEMPT-RT.

(But PREEMPT-RT will make the whole kernel deterministic, right? ;)

Adding low-latency channels (eg. working against coalescing) will be a very hard sell upstream.

Richard

#15 lore raw
Quoted 9 lines · Richard Cochran
Quoted 8 lines · Jan Kiszka
Quoted 6 lines · Jan Kiszka

I was simply hoping to collect some new ideas how to address the driver maintenance issue in a better way but without dropping key features needed for RT networking. Something like "let's add generic RT channels to Linux upstream drivers and then only patch them fit RTDM". Not sure if that works, but it would come with a vision how to keep things more maintainable.

Quoted 3 lines
Quoted 1 line

+this could be useful for other scenarios - on PREEMPT-RT.

(But PREEMPT-RT will make the whole kernel deterministic, right? ;)

Yes. Except where not.

Quoted 3 lines

Adding low-latency channels (eg. working against coalescing) will be a very hard sell upstream.

That also depends on the invasiveness. Key requirements like separate packet pools slowly sneak in (for swap over net). Also, separate IRQs for separate channels on modern NICs may make the split-out smoother - you may no longer need to disable features that used to affect the same handler or shared some locks.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#16 lore raw
In reply to Jan Kiszka
Quoted 6 lines · Jan Kiszka

On 2011-09-27 18:05, Richard Cochran wrote:

That's a common misunderstanding: RTnet is a networking stack with many _optional_ components (like RTmac, RTcfg etc.). I would bet that it's more frequently used today in minimal setups, i.e. just the core, some driver, and either PF_PACKET or UDP/IP.

I understood about the modular design, but I really want to know if rtnet will help me if I want to use of the industrial Ethernet protocols. AFAICT, rtnet really doesn't offer these.

So I'll ask the direct question once again. Does rtnet help me with industrial Ethernet (apart from the rtnet protocols), or not?

Quoted 9 lines
Quoted 6 lines

Unless rtnet implements (or helps to implement) these, it is kind of silly to say, "your way won't work, you should use rtnet instead."

I don't know PowerLink or Profinet, but I do know EtherCAT and IEC 61850, and those two can surely be implemented on the interface that I am talking about.

It works, but it won't give you a deterministic control loop as you still have Linux in the game.

It really depends on how the driver is written. While my gianfar example does make use of normal Linux driver interrupts, it would not necessarily have to do so.

Quoted 6 lines

I was simply hoping to collect some new ideas how to address the driver maintenance issue in a better way but without dropping key features needed for RT networking. Something like "let's add generic RT channels to Linux upstream drivers and then only patch them fit RTDM". Not sure if that works, but it would come with a vision how to keep things more maintainable.

Well, can you turn the issue around and convince me that writing a rtnet driver is the best way to acheive raw Ethernet packet access?

You talk about the rtnet driver model, but is it described anywhere?

(BTW rtnet/Documentation/README.drvporting is horrible. It is just a random list of 40+ odd points without any sense. That document gave me the impression that developing an rtnet driver is a kind of extended "hack until it starts working.")

Thanks,
Richard

#17 lore raw
Quoted 8 lines · Richard Cochran
Quoted 6 lines · Jan Kiszka

On 2011-09-27 18:05, Richard Cochran wrote:

That's a common misunderstanding: RTnet is a networking stack with many _optional_ components (like RTmac, RTcfg etc.). I would bet that it's more frequently used today in minimal setups, i.e. just the core, some driver, and either PF_PACKET or UDP/IP.

Quoted 6 lines

I understood about the modular design, but I really want to know if rtnet will help me if I want to use of the industrial Ethernet protocols. AFAICT, rtnet really doesn't offer these.

So I'll ask the direct question once again. Does rtnet help me with industrial Ethernet (apart from the rtnet protocols), or not?

It manages buffers for you, provides NIC drivers and interfaces to either build the higher protocol layers in the kernel or in user space. That's the mission, but I would not exclude that there is room for improvements (lacking safe copy-to/from user, unneeded RX thread for single-user scenarios and possibly more). Still, the Ethercat master library folks chose it back then as a platform, maybe you want to ask them.

Quoted 22 lines
Quoted 10 lines
Quoted 7 lines

Unless rtnet implements (or helps to implement) these, it is kind of silly to say, "your way won't work, you should use rtnet instead."

I don't know PowerLink or Profinet, but I do know EtherCAT and IEC 61850, and those two can surely be implemented on the interface that I am talking about.

It works, but it won't give you a deterministic control loop as you still have Linux in the game.

It really depends on how the driver is written. While my gianfar example does make use of normal Linux driver interrupts, it would not necessarily have to do so.

Quoted 6 lines

I was simply hoping to collect some new ideas how to address the driver maintenance issue in a better way but without dropping key features needed for RT networking. Something like "let's add generic RT channels to Linux upstream drivers and then only patch them fit RTDM". Not sure if that works, but it would come with a vision how to keep things more maintainable.

Quoted 2 lines

Well, can you turn the issue around and convince me that writing a rtnet driver is the best way to acheive raw Ethernet packet access?

It would at least avoid having to reinvent user interfaces and buffer management layers. They may appear simple now, but that's how everything once started.

Quoted 7 lines

You talk about the rtnet driver model, but is it described anywhere?

(BTW rtnet/Documentation/README.drvporting is horrible. It is just a random list of 40+ odd points without any sense. That document gave me the impression that developing an rtnet driver is a kind of extended "hack until it starts working.")

I know best. It once worked well, allowed you to more or less mechanically convert a driver within a few hours, but that's quite a few years ago. Driver complexity almost exploded since then.

But my goal is not necessarily convincing you to use current RTnet as is, but to make you think ahead, reusing the experience of this project if you start something new. That need not replace RTnet immediately, but it should not block a transition architecturally. The first step to this remains studying the legacy, even if not using it in the end.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#18 lore raw
Quoted 7 lines · Jan Kiszka

It manages buffers for you, provides NIC drivers and interfaces to either build the higher protocol layers in the kernel or in user space. That's the mission, but I would not exclude that there is room for improvements (lacking safe copy-to/from user, unneeded RX thread for single-user scenarios and possibly more). Still, the Ethercat master library folks chose it back then as a platform, maybe you want to ask them.

Getting a little off topic, I wonder, who are these "Ethercat folks" of whom you speak?

I do know of a few open source implementations, but none are based Xenomai:

* IgH etherlab
This is a complete stack in the kernel. Although they claim it works with Xenomai, in fact it does not, since it uses regular kernel spin locks, etc. However, it could be adapted to work with Xenomai.
* SOEM
This is a user space (really simple) stack based on normal raw sockets. It could also be adapted to use Xenomai, by adding some sort of raw RT socket.
* OSADL
This was withdrawn because of license concerns. I never saw the code, but I do beleive it was a user space solution using standard sockets.
* Another?
There once was some C++ program from some institute in the Netherlands (or Belgium? can't remember), but it was also withdrawn.

So, did you mean any of these, or yet another implementation?

Thanks,
Richard

#19 lore raw
Quoted 31 lines · Richard Cochran
Quoted 7 lines · Jan Kiszka

It manages buffers for you, provides NIC drivers and interfaces to either build the higher protocol layers in the kernel or in user space. That's the mission, but I would not exclude that there is room for improvements (lacking safe copy-to/from user, unneeded RX thread for single-user scenarios and possibly more). Still, the Ethercat master library folks chose it back then as a platform, maybe you want to ask them.

Getting a little off topic, I wonder, who are these "Ethercat folks" of whom you speak?

I do know of a few open source implementations, but none are based Xenomai:

* IgH etherlab
This is a complete stack in the kernel. Although they claim it works with Xenomai, in fact it does not, since it uses regular kernel spin locks, etc. However, it could be adapted to work with Xenomai.
* SOEM
This is a user space (really simple) stack based on normal raw sockets. It could also be adapted to use Xenomai, by adding some sort of raw RT socket.
* OSADL
This was withdrawn because of license concerns. I never saw the code, but I do beleive it was a user space solution using standard sockets.
* Another?
There once was some C++ program from some institute in the Netherlands (or Belgium? can't remember), but it was also withdrawn.

Quoted 1 line

So, did you mean any of these, or yet another implementation?

I meat the first hit for "ethercat master library" in a search engine. See

http://ethercatmaster.berlios.de/
http://www.fmtc.be/downloads/15_FMTC%20open%20sources.pdf

or ask Peter or Klaas ([email protected], [email protected] - not sure if Klaas is still with fmtc).

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#20 lore raw
In reply to Richard Cochran
Quoted 36 lines · Richard Cochran
Quoted 6 lines · Jan Kiszka

On 2011-09-27 18:05, Richard Cochran wrote:

That's a common misunderstanding: RTnet is a networking stack with many _optional_ components (like RTmac, RTcfg etc.). I would bet that it's more frequently used today in minimal setups, i.e. just the core, some driver, and either PF_PACKET or UDP/IP.

I understood about the modular design, but I really want to know if rtnet will help me if I want to use of the industrial Ethernet protocols. AFAICT, rtnet really doesn't offer these.

So I'll ask the direct question once again. Does rtnet help me with industrial Ethernet (apart from the rtnet protocols), or not?

Quoted 9 lines
Quoted 6 lines

Unless rtnet implements (or helps to implement) these, it is kind of silly to say, "your way won't work, you should use rtnet instead."

I don't know PowerLink or Profinet, but I do know EtherCAT and IEC 61850, and those two can surely be implemented on the interface that I am talking about.

It works, but it won't give you a deterministic control loop as you still have Linux in the game.

It really depends on how the driver is written. While my gianfar example does make use of normal Linux driver interrupts, it would not necessarily have to do so.

Quoted 6 lines

I was simply hoping to collect some new ideas how to address the driver maintenance issue in a better way but without dropping key features needed for RT networking. Something like "let's add generic RT channels to Linux upstream drivers and then only patch them fit RTDM". Not sure if that works, but it would come with a vision how to keep things more maintainable.

Quoted 4 lines

Well, can you turn the issue around and convince me that writing a rtnet driver is the best way to acheive raw Ethernet packet access?

From the point of view of someone a bit external to the rtnet project,

rtnet is a TCP/IP stack, which contains the stack, useless for your purposes, but defines an interface between drivers and the stack. By following this interface to write a driver on one-side, and support for raw packets on the other side you get:
- raw packets support for all drivers in rtnet repository
- TCP/IP support for the NIC you wrote a driver for.

As for the in-kernel driver patch versus out-of-tree driver, in-kernel driver will have to be adapted for each release of the linux kernel, when porting the I-pipe patch, and that is quickly going to become a nightmare.

Quoted 6 lines

You talk about the rtnet driver model, but is it described anywhere?

(BTW rtnet/Documentation/README.drvporting is horrible. It is just a random list of 40+ odd points without any sense. That document gave me the impression that developing an rtnet driver is a kind of extended "hack until it starts working.")

README.drvporting is frightening at first, but in fact, the job to port a network driver to rtnet is not so hard.

Quoted 9 lines

Thanks,
Richard

_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core

Signature · 1 line
                                                                Gilles.