Skip to contentSkip to conversation

net: arinc429: Add ARINC-429 stack

RFC PATCH In review Marek Vasut 5 participants 46 messages Nov 1, 2015 – Nov 18, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 net: arinc429: Add ARINC-429 stack

The ARINC-429 is a technical standard, which describes, among others, a data bus used by airplanes. The standard contains much more, since it is based off the ISO/OSI model, but this patch implements just the data bus protocol.

This stack is derived from the SocketCAN implementation, already present in the kernel and thus behaves in a very similar fashion. Thus far, we support sending RAW ARINC-429 datagrams, configuration of the RX and TX clock speed and filtering.

The ARINC-429 datagram is four-byte long. The first byte is always the LABEL, the function of remaining three bytes can vary, so we handle it as an opaque PAYLOAD. The userspace tools can send these datagrams via a standard socket.

A LABEL-based filtering can be configured on each socket separately in a way comparable to CAN -- user uses setsockopt() to push a list of label,mask tuples into the kernel and the kernel will deliver a datagram to the socket if (<received_label> & mask) == (label & mask), otherwise the datagram is not delivered.

Cc David S. Miller" <[email protected]>
Cc Oliver Hartkopp <[email protected]>
Cc Marc Kleine-Budde <[email protected]>
Cc Wolfgang Grandegger <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Andrey Vostrikov <[email protected]>

To: [email protected]

---
 MAINTAINERS                           |  19 +
 drivers/net/Makefile                  |   1 +
 drivers/net/arinc429/Kconfig          |  32 ++
 drivers/net/arinc429/Makefile         |  11 +
 drivers/net/arinc429/dev.c            | 448 +++++++++++++++++++
 drivers/net/arinc429/varinc429.c      | 163 +++++++
 include/linux/arinc429/core.h         |  61 +++
 include/linux/arinc429/dev.h          |  81 ++++
 include/linux/arinc429/skb.h          |  79 ++++
 include/linux/socket.h                |   4 +-
 include/uapi/linux/arinc429.h         |  88 ++++
 include/uapi/linux/arinc429/Kbuild    |   6 +
 include/uapi/linux/arinc429/netlink.h |  55 +++
 include/uapi/linux/arinc429/raw.h     |  36 ++
 include/uapi/linux/if_arp.h           |   1 +
 include/uapi/linux/if_ether.h         |   1 +
 net/Kconfig                           |   1 +
 net/Makefile                          |   1 +
 net/arinc429/Kconfig                  |  31 ++
 net/arinc429/Makefile                 |   9 +
 net/arinc429/af_arinc429.c            | 812 ++++++++++++++++++++++++++++++++++
 net/arinc429/af_arinc429.h            | 100 +++++
 net/arinc429/proc.c                   | 432 ++++++++++++++++++
 net/arinc429/raw.c                    | 758 +++++++++++++++++++++++++++++++
 24 files changed, 3229 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/arinc429/Kconfig
 create mode 100644 drivers/net/arinc429/Makefile
 create mode 100644 drivers/net/arinc429/dev.c
 create mode 100644 drivers/net/arinc429/varinc429.c
 create mode 100644 include/linux/arinc429/core.h
 create mode 100644 include/linux/arinc429/dev.h
 create mode 100644 include/linux/arinc429/skb.h
 create mode 100644 include/uapi/linux/arinc429.h
 create mode 100644 include/uapi/linux/arinc429/Kbuild
 create mode 100644 include/uapi/linux/arinc429/netlink.h
 create mode 100644 include/uapi/linux/arinc429/raw.h
 create mode 100644 net/arinc429/Kconfig
 create mode 100644 net/arinc429/Makefile
 create mode 100644 net/arinc429/af_arinc429.c
 create mode 100644 net/arinc429/af_arinc429.h
 create mode 100644 net/arinc429/proc.c
 create mode 100644 net/arinc429/raw.c
MAINTAINERS +19 -0
index 9de185d..cfa3a92 100644
@@ -814,6 +814,25 @@ S:	Maintained
 F:	drivers/net/arcnet/
 F:	include/uapi/linux/if_arcnet.h
 
+ARINC429 NETWORK LAYER
+M:	Marek Vasut <[email protected]>
+S:	Maintained
+F:	net/arinc429/
+F:	include/linux/arinc429/core.h
+F:	include/uapi/linux/arinc429.h
+F:	include/uapi/linux/arinc429/bcm.h
+F:	include/uapi/linux/arinc429/raw.h
+F:	include/uapi/linux/arinc429/gw.h
+
+ARINC429 NETWORK DRIVERS
+M:	Marek Vasut <[email protected]>
+S:	Maintained
+F:	drivers/net/arinc429/
+F:	include/linux/arinc429/dev.h
+F:	include/linux/arinc429/platform/
+F:	include/uapi/linux/arinc429/error.h
+F:	include/uapi/linux/arinc429/netlink.h
+
 ARM MFM AND FLOPPY DRIVERS
 M:	Ian Molton <[email protected]>
 S:	Maintained
drivers/net/Makefile +1 -0
index 900b0c5..d6e0682 100644
@@ -31,6 +31,7 @@ obj-$(CONFIG_NET_VRF) += vrf.o
 # Networking Drivers
 #
 obj-$(CONFIG_ARCNET) += arcnet/
+obj-$(CONFIG_ARINC429) += arinc429/
 obj-$(CONFIG_DEV_APPLETALK) += appletalk/
 obj-$(CONFIG_CAIF) += caif/
 obj-$(CONFIG_CAN) += can/
drivers/net/arinc429/Kconfig new file +32 -0
new file mode 100644
index 0000000..428164c
@@ -0,0 +1,32 @@
+menu "ARINC429 Device Drivers"
+
+config ARINC429_VARINC429
+	tristate "Virtual Local ARINC429 Interface (varinc429)"
+	---help---
+	  Similar to the network loopback devices, varinc429 offers a
+	  virtual local ARINC429 interface.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called varinc429.
+
+config ARINC429_DEV
+	tristate "Platform ARINC429 drivers with Netlink support"
+	default y
+	---help---
+	  Enables the common framework for platform ARINC429 drivers with Netlink
+	  support. This is the standard library for ARINC429 drivers.
+	  If unsure, say Y.
+
+if ARINC429_DEV
+
+endif
+
+config ARINC429_DEBUG_DEVICES
+	bool "ARINC429 devices debugging messages"
+	---help---
+	  Say Y here if you want the ARINC429 device drivers to produce a bunch of
+	  debug messages to the system log.  Select this if you are having
+	  a problem with ARINC429 support and want to see more of what is going
+	  on.
+
+endmenu
drivers/net/arinc429/Makefile new file +11 -0
new file mode 100644
index 0000000..70aaaac
@@ -0,0 +1,11 @@
+#
+#  Makefile for the Linux Controller Area Network drivers.
+#
+
+obj-$(CONFIG_ARINC429_VARINC429)	+= varinc429.o
+
+obj-$(CONFIG_ARINC429_DEV)		+= arinc429-dev.o
+arinc429-dev-y				:= dev.o
+
+subdir-ccflags-y += -D__CHECK_ENDIAN__
+subdir-ccflags-$(CONFIG_ARINC429_DEBUG_DEVICES) += -DDEBUG
drivers/net/arinc429/dev.c new file +448 -0

448 lines not on this page · raw message

drivers/net/arinc429/varinc429.c new file +163 -0

163 lines not on this page · raw message

include/linux/arinc429/core.h new file +61 -0

61 lines not on this page · raw message

include/linux/arinc429/dev.h new file +81 -0

81 lines not on this page · raw message

include/linux/arinc429/skb.h new file +79 -0

79 lines not on this page · raw message

include/linux/socket.h +3 -1
index 5bf59c8..627d4af 100644
@@ -200,7 +200,8 @@ struct ucred {
 #define AF_ALG		38	/* Algorithm sockets		*/
 #define AF_NFC		39	/* NFC sockets			*/
 #define AF_VSOCK	40	/* vSockets			*/
-#define AF_MAX		41	/* For now.. */
+#define AF_ARINC429	41	/* ARINC429			*/
+#define AF_MAX		42	/* For now.. */
 
 /* Protocol families, same as address families. */
 #define PF_UNSPEC	AF_UNSPEC
@@ -246,6 +247,7 @@ struct ucred {
 #define PF_ALG		AF_ALG
 #define PF_NFC		AF_NFC
 #define PF_VSOCK	AF_VSOCK
+#define PF_ARINC429	AF_ARINC429
 #define PF_MAX		AF_MAX
 
 /* Maximum queue length specifiable by listen.  */
include/uapi/linux/arinc429.h new file +88 -0

88 lines not on this page · raw message

include/uapi/linux/arinc429/Kbuild new file +6 -0
new file mode 100644
index 0000000..21c91bf
@@ -0,0 +1,6 @@
+# UAPI Header export list
+header-y += bcm.h
+header-y += error.h
+header-y += gw.h
+header-y += netlink.h
+header-y += raw.h
include/uapi/linux/arinc429/netlink.h new file +55 -0

55 lines not on this page · raw message

include/uapi/linux/arinc429/raw.h new file +36 -0
new file mode 100644
index 0000000..e951148
@@ -0,0 +1,36 @@
+/*
+ * linux/arinc429/raw.h
+ *
+ * Definitions for raw ARINC429 sockets
+ *
+ * Copyright (C) 2015 Marek Vasut <[email protected]>
+ *
+ * Based on the SocketCAN stack.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
+ *
+ * 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.
+ */
+
+#ifndef _UAPI_ARINC429_RAW_H
+#define _UAPI_ARINC429_RAW_H
+
+#include <linux/arinc429.h>
+
+#define SOL_ARINC429_RAW (SOL_ARINC429_BASE + ARINC429_RAW)
+
+/* for socket options affecting the socket (not the global system) */
+
+enum {
+	ARINC429_RAW_FILTER = 1,	/* set 0 .. n arinc429_filter(s)     */
+	ARINC429_RAW_LOOPBACK,		/* local loopback (default:on)       */
+	ARINC429_RAW_RECV_OWN_MSGS,	/* receive my own msgs (default:off) */
+	ARINC429_RAW_JOIN_FILTERS,	/* all filters must match to trigger */
+};
+
+#endif /* !_UAPI_ARINC429_RAW_H */
include/uapi/linux/if_arp.h +1 -0
index 4d024d7..3457947 100644
@@ -53,6 +53,7 @@
 #define ARPHRD_X25	271		/* CCITT X.25			*/
 #define ARPHRD_HWX25	272		/* Boards with X.25 in firmware	*/
 #define ARPHRD_CAN	280		/* Controller Area Network      */
+#define ARPHRD_ARINC429	281		/* ARINC429			*/
 #define ARPHRD_PPP	512
 #define ARPHRD_CISCO	513		/* Cisco HDLC	 		*/
 #define ARPHRD_HDLC	ARPHRD_CISCO
include/uapi/linux/if_ether.h +1 -0
index ea9221b..8bbe328 100644
@@ -126,6 +126,7 @@
 #define ETH_P_ARCNET	0x001A		/* 1A for ArcNet :-)            */
 #define ETH_P_DSA	0x001B		/* Distributed Switch Arch.	*/
 #define ETH_P_TRAILER	0x001C		/* Trailer switch tagging	*/
+#define ETH_P_ARINC429	0x001D		/* ARINC429			*/
 #define ETH_P_PHONET	0x00F5		/* Nokia Phonet frames          */
 #define ETH_P_IEEE802154 0x00F6		/* IEEE802.15.4 frame		*/
 #define ETH_P_CAIF	0x00F7		/* ST-Ericsson CAIF protocol	*/
net/Kconfig +1 -0
index 7021c1b..ec5efaa 100644
@@ -345,6 +345,7 @@ endmenu
 
 endmenu
 
+source "net/arinc429/Kconfig"
 source "net/ax25/Kconfig"
 source "net/can/Kconfig"
 source "net/irda/Kconfig"
net/Makefile +1 -0
index 3995613..b3ee049 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_X25)		+= x25/
 obj-$(CONFIG_LAPB)		+= lapb/
 obj-$(CONFIG_NETROM)		+= netrom/
 obj-$(CONFIG_ROSE)		+= rose/
+obj-$(CONFIG_ARINC429)		+= arinc429/
 obj-$(CONFIG_AX25)		+= ax25/
 obj-$(CONFIG_CAN)		+= can/
 obj-$(CONFIG_IRDA)		+= irda/
net/arinc429/Kconfig new file +31 -0
new file mode 100644
index 0000000..2952123
@@ -0,0 +1,31 @@
+#
+# ARINC429 network layer core configuration
+#
+
+menuconfig ARINC429
+	depends on NET
+	tristate "ARINC429 bus subsystem support"
+	---help---
+	  ARINC429 is a slow communication protocol used in avionics.
+	  More information on the ARINC429 protocol family PF_ARINC429
+	  is contained in <Documentation/networking/arinc429.txt>.
+
+	  If you want ARINC429 support you should say Y here and also to
+	  the specific driver for your controller(s) below.
+
+if ARINC429
+
+config ARINC429_RAW
+	tristate "Raw ARINC429 Protocol"
+	default y
+	---help---
+	  The raw ARINC429 protocol option offers access to the ARINC429
+	  bus via the BSD socket API. You probably want to use the raw
+	  socket in most cases where no higher level protocol is being
+	  used. The raw socket has several filter options e.g. ID masking
+	  / error frames. To receive/send raw ARINC429 messages, use AF_ARINC429
+	  with protocol ARINC429_RAW.
+
+source "drivers/net/arinc429/Kconfig"
+
+endif
net/arinc429/Makefile new file +9 -0
new file mode 100644
index 0000000..f444729
@@ -0,0 +1,9 @@
+#
+#  Makefile for the Linux Controller Area Network core.
+#
+
+obj-$(CONFIG_ARINC429)		+= arinc429.o
+arinc429-y			:= af_arinc429.o proc.o
+
+obj-$(CONFIG_ARINC429_RAW)	+= arinc429-raw.o
+arinc429-raw-y			:= raw.o
net/arinc429/af_arinc429.c new file +812 -0

812 lines not on this page · raw message

net/arinc429/af_arinc429.h new file +100 -0

100 lines not on this page · raw message

net/arinc429/proc.c new file +432 -0

432 lines not on this page · raw message

net/arinc429/raw.c new file +758 -0

480 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.1.4

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 15 lines · Marek Vasut

The ARINC-429 is a technical standard, which describes, among others, a data bus used by airplanes. The standard contains much more, since it is based off the ISO/OSI model, but this patch implements just the data bus protocol.

This stack is derived from the SocketCAN implementation, already present in the kernel and thus behaves in a very similar fashion. Thus far, we support sending RAW ARINC-429 datagrams, configuration of the RX and TX clock speed and filtering.

The ARINC-429 datagram is four-byte long. The first byte is always the LABEL, the function of remaining three bytes can vary, so we handle it as an opaque PAYLOAD. The userspace tools can send these datagrams via a standard socket.

Quoted 5 lines

A LABEL-based filtering can be configured on each socket separately in a way comparable to CAN -- user uses setsockopt() to push a list of label,mask tuples into the kernel and the kernel will deliver a datagram to the socket if (<received_label> & mask) == (label & mask), otherwise the datagram is not delivered.

What's difference compared to CAN besides a different MTU? The CAN stack is already capable to handle CAN and CAN-FD frames. Would it make sense to integrate the ARINC-429 into the existing CAN stack?

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
#2 lore raw
Quoted 22 lines · Marc Kleine-Budde
Quoted 15 lines · Marek Vasut

The ARINC-429 is a technical standard, which describes, among others, a data bus used by airplanes. The standard contains much more, since it is based off the ISO/OSI model, but this patch implements just the data bus protocol.

This stack is derived from the SocketCAN implementation, already present in the kernel and thus behaves in a very similar fashion. Thus far, we support sending RAW ARINC-429 datagrams, configuration of the RX and TX clock speed and filtering.

The ARINC-429 datagram is four-byte long. The first byte is always the LABEL, the function of remaining three bytes can vary, so we handle it as an opaque PAYLOAD. The userspace tools can send these datagrams via a standard socket.

Quoted 5 lines

A LABEL-based filtering can be configured on each socket separately in a way comparable to CAN -- user uses setsockopt() to push a list of label,mask tuples into the kernel and the kernel will deliver a datagram to the socket if (<received_label> & mask) == (label & mask), otherwise the datagram is not delivered.

Quoted 3 lines

What's difference compared to CAN besides a different MTU? The CAN stack is already capable to handle CAN and CAN-FD frames. Would it make sense to integrate the ARINC-429 into the existing CAN stack?

That was my first impression too.

What about defining some overlay data structure to map ARINC-429 frames into CAN frames?

E.g. we could write the ARINC 32 bit data completely into data[0..3] and additionally copy the 8 bit label information (or should it better be 10 bit including the Source/Destination Identifiers?) additionally into the can_id.

From what I can see the filtering by label is similar to filtering by can_id. And you would be able to use the can-gw functionality too.

The only real difference is the bitrate configuration of the ARINC interface.

I wonder if a similar approach would fit here as we discussed with the University of Prague for a LIN implementation using the PF_CAN infrastructure:

http://rtime.felk.cvut.cz/can/lin-bus/

It could probably boil down to a 'CAN interface' that is named arinc0 which implements the serial driver like in slcan.c or sllin.c ...

Regards,
Oliver

#3 lore raw
Quoted 7 lines · Oliver Hartkopp

What about defining some overlay data structure to map ARINC-429 frames into CAN frames?

E.g. we could write the ARINC 32 bit data completely into data[0..3] and additionally copy the 8 bit label information (or should it better be 10 bit including the Source/Destination Identifiers?) additionally into the can_id.

Note that the only bits which are always treated as non-data are the 8 label bits (well, and the parity bit #31). The 2 SDI bits (#8, #9) may be used as data bits when a high resolution is needed, like Lat/Long encoded in binary words 310 and 311. I wouldn't make any assumption on what's on those 2 bits; i.e. they're not always "source/destination".

Signature · 2 lines
Aleksander
https://aleksander.es
#4 lore raw
Quoted 9 lines · Aleksander Morgado
Quoted 7 lines · Oliver Hartkopp

What about defining some overlay data structure to map ARINC-429 frames into CAN frames?

E.g. we could write the ARINC 32 bit data completely into data[0..3] and additionally copy the 8 bit label information (or should it better be 10 bit including the Source/Destination Identifiers?) additionally into the can_id.

Quoted 6 lines

Note that the only bits which are always treated as non-data are the 8 label bits (well, and the parity bit #31). The 2 SDI bits (#8, #9) may be used as data bits when a high resolution is needed, like Lat/Long encoded in binary words 310 and 311. I wouldn't make any assumption on what's on those 2 bits; i.e. they're not always "source/destination".

You definitely know these details better than me. That's why I'm asking.

Would hosting the 32 bit in the struct can_frame.data and just the 8 bit label in struct can_frame.can_id offer the functionality you need?

Besides the arinc429_frame struct

struct arinc429_frame {
	__u8	label;		/* 8 bit label */
	__u8	data[3];	/* Up-to 23 bits are valid. */
};

everything else roughly looks like copy&paste from PF_CAN with renaming.

So when we can fit the arinc frames into CAN frames and re-use the existing CAN infrastructure - we are almost done.

Regards,
Oliver

#5 lore raw
In reply to Oliver Hartkopp
Quoted 23 lines · Oliver Hartkopp
Quoted 22 lines · Marc Kleine-Budde
Quoted 20 lines · Marek Vasut

The ARINC-429 is a technical standard, which describes, among others, a data bus used by airplanes. The standard contains much more, since it is based off the ISO/OSI model, but this patch implements just the data bus protocol.

This stack is derived from the SocketCAN implementation, already present in the kernel and thus behaves in a very similar fashion. Thus far, we support sending RAW ARINC-429 datagrams, configuration of the RX and TX clock speed and filtering.

The ARINC-429 datagram is four-byte long. The first byte is always the LABEL, the function of remaining three bytes can vary, so we handle it as an opaque PAYLOAD. The userspace tools can send these datagrams via a standard socket.

A LABEL-based filtering can be configured on each socket separately in a way comparable to CAN -- user uses setsockopt() to push a list of label,mask tuples into the kernel and the kernel will deliver a datagram to the socket if (<received_label> & mask) == (label & mask), otherwise the datagram is not delivered.

Quoted 5 lines
Quoted 3 lines

What's difference compared to CAN besides a different MTU? The CAN stack is already capable to handle CAN and CAN-FD frames. Would it make sense to integrate the ARINC-429 into the existing CAN stack?

That was my first impression too.

Hi!

Quoted 2 lines

What about defining some overlay data structure to map ARINC-429 frames into CAN frames?

I agree about the code reuse, it was stupid to do such a blatant copy of the code all right. I don't think it's such a great idea to outright place ARINC support into the CAN stack though. They're two different busses after all. Please see below.

Quoted 7 lines

E.g. we could write the ARINC 32 bit data completely into data[0..3] and additionally copy the 8 bit label information (or should it better be 10 bit including the Source/Destination Identifiers?) additionally into the can_id.

From what I can see the filtering by label is similar to filtering by
can_id. And you would be able to use the can-gw functionality too.

This is correct.

Quoted 2 lines

The only real difference is the bitrate configuration of the ARINC interface.

There might be additional ARINC-specific configuration bits involved, but thus far, that's correct.

Quoted 3 lines

I wonder if a similar approach would fit here as we discussed with the University of Prague for a LIN implementation using the PF_CAN infrastructure:

OT: Hey, there is no "University of Prague", there are two universities in Prague to boot -- Charles University and Czech Technical University -- you mean the later ;-)

Quoted 4 lines

http://rtime.felk.cvut.cz/can/lin-bus/

It could probably boil down to a 'CAN interface' that is named arinc0 which implements the serial driver like in slcan.c or sllin.c ...

I was thinking about this and I mostly agree with you. Obviously, copying the code this way was dumb. On the other hand, ARINC and CAN are two different sort of busses, so I'd propose something slightly different here to avoid confusion and prevent the future extensions (or protocols) from adding unrelated cruft into the CAN stack.

I would propose we (read: me) create some sort of "common" core, which would contain the following:
- drivers/net/: big part of the device interface here is common big part of the virtual interface here is common -> CAN or ARINC can just add their own specific callbacks and be done with it

- net/: there's a lot of common parts as well, like the filtering can be unified such that it can be used by both. A big part of the socket handling is also similar.

This would also let the slcan or sllin or whatever stuff they made at CVUT just plug into this "common" core part.

Now I wonder if we should introduce AF_ARINC or stick to AF_CAN for both. I'd be much happier to keep those two separate, again, to avoid confusion.

What do you think please ?

Best regards,
Marek Vasut

#6 lore raw

Hi,

Quoted 5 lines

I was thinking about this and I mostly agree with you. Obviously, copying the code this way was dumb. On the other hand, ARINC and CAN are two different sort of busses, so I'd propose something slightly different here to avoid confusion and prevent the future extensions (or protocols) from adding unrelated cruft into the CAN stack.

Another major difference between CAN and ARINC429 is that ARINC is simplex. It does not need loopback and echo. For example HOLT IC chip HI-3593 has two receivers and single transmitter, which should be instantiated as separate devices, as each channel could be connected to different network.

It would be nice if new ARINC framework will provide means to create RX or TX only network device and have -rx- or -tx- as part of device name.

Label space in ARINC is much smaller than in CAN, is it really needed to have hash and masks? May be simple bitmap for 256 bits will fit better. At least it could be directly provided to mentioned HOLT chip to do filtering in hardware.

Signature · 2 lines
Best regards,
Andrey
#7 lore raw
Quoted 1 line · Vostrikov Andrey

Hi,

Hi,

Quoted 11 lines
Quoted 5 lines

I was thinking about this and I mostly agree with you. Obviously, copying the code this way was dumb. On the other hand, ARINC and CAN are two different sort of busses, so I'd propose something slightly different here to avoid confusion and prevent the future extensions (or protocols) from adding unrelated cruft into the CAN stack.

Another major difference between CAN and ARINC429 is that ARINC is simplex. It does not need loopback and echo. For example HOLT IC chip HI-3593 has two receivers and single transmitter, which should be instantiated as separate devices, as each channel could be connected to different network.

So this would effectively be three devices, correct ? I think you can just register a regular ARINC device for each channel and be done with it. Loopback and echo can be configurable.

Quoted 3 lines

It would be nice if new ARINC framework will provide means to create RX or TX only network device and have -rx- or -tx- as part of device name.

I'd say you can fail the TX if you're trying to send via an RX-only channel. The naming can probably be also tweaked, but I don't see much value in that, especially since you can rename those interfaces by using udev rules. Checking if the interface supports RX/TX should be done by other means, not the name.

Quoted 4 lines

Label space in ARINC is much smaller than in CAN, is it really needed to have hash and masks? May be simple bitmap for 256 bits will fit better. At least it could be directly provided to mentioned HOLT chip to do filtering in hardware.

CAN does the can_id filtering this way and I find it familiar and convenient, so I don't see a reason not to re-use it. If the hardware has some special support for the frame filtering, it's the driver that should convert the filter specification into form which the hardware understands -- this sort of configuration is done only once at the beginning of operation, so some small overhead of the conversion of the filter setting should be acceptable, we're talking about generating 256 entries for the hardware from ID/mask tuple, no big deal here.

Best regards,
Marek Vasut

#8 lore raw

Hey!

Quoted 6 lines · Marek Vasut
Quoted 6 lines
Quoted 5 lines

I was thinking about this and I mostly agree with you. Obviously, copying the code this way was dumb. On the other hand, ARINC and CAN are two different sort of busses, so I'd propose something slightly different here to avoid confusion and prevent the future extensions (or protocols) from adding unrelated cruft into the CAN stack.

I'd keep them separate not because ARINC may add unrelated cruft into the CAN stack, but because ARINC is much simpler than CAN already...

Quoted 10 lines
Quoted 5 lines

Another major difference between CAN and ARINC429 is that ARINC is simplex. It does not need loopback and echo. For example HOLT IC chip HI-3593 has two receivers and single transmitter, which should be instantiated as separate devices, as each channel could be connected to different network.

So this would effectively be three devices, correct ? I think you can just register a regular ARINC device for each channel and be done with it. Loopback and echo can be configurable.

I tend to agree with Andrey here; I'm not sure I see any use case for the echo feature (a TX channel is a TX channel, you don't expect anything back), and just testing purposes for the loopback.

Quoted 9 lines
Quoted 3 lines

It would be nice if new ARINC framework will provide means to create RX or TX only network device and have -rx- or -tx- as part of device name.

I'd say you can fail the TX if you're trying to send via an RX-only channel. The naming can probably be also tweaked, but I don't see much value in that, especially since you can rename those interfaces by using udev rules. Checking if the interface supports RX/TX should be done by other means, not the name.

I don't like the naming change specifying whether -rx or -tx, but it's true that there are no real channels doing RX and TX at the same time. You may have a device with multiple channels, and in that case you may have RX channels and TX channels in the same device, but then the RX and TX channels may be connected to different buses. Systems will usually do either TX or RX; and for the case where both things could make sense (I have a simulator setup that I use that way), the direct way is to interconnect a TX port with a RX port physically.

Quoted 5 lines
Quoted 4 lines

Label space in ARINC is much smaller than in CAN, is it really needed to have hash and masks? May be simple bitmap for 256 bits will fit better. At least it could be directly provided to mentioned HOLT chip to do filtering in hardware.

Quoted 8 lines

CAN does the can_id filtering this way and I find it familiar and convenient, so I don't see a reason not to re-use it. If the hardware has some special support for the frame filtering, it's the driver that should convert the filter specification into form which the hardware understands -- this sort of configuration is done only once at the beginning of operation, so some small overhead of the conversion of the filter setting should be acceptable, we're talking about generating 256 entries for the hardware from ID/mask tuple, no big deal here.

I also tend to see this filtering setup a bit of over-engineered for ARINC429. A fixed-sized 256 bitmask per socket to specify which labels are wanted is more than enough. And that will then actually have a direct relationship with the hardware label filtering setup. It's true that the filter list is built at the beginning, but the filters then need to get applied per ARINC word received.

Also, this setup is forcing users to look for the minimum set of filters to match the labels they want to receive. In practice, users will just want to receive a given set of labels and would likely end up with one filter per label wanted with a 0xFF mask to match the full label they want. I'd prefer if the users could just give a 256 bit mask, one bit per ARINC label wanted, it would make much more sense. All this complex filtering setup, including the inverse filter (no clear usecase for that), looks a bit out of context in ARINC429. The filtering interface and implementation could be much simpler and I believe it would actually fit better what users expect from it.

Unrelated to all this, another key point in ARINC is the timing for each label when transmitting. The common case you get is different labels being sent continuously with a given rate for each. E.g. labels 310 and 311 every 80ms, label 312 every 120ms and so on. I'm not sure the HOLT chips have any specific way of configuring this, but I've seen some USB devices which actually have APIs to say e.g. "send label 310 every 80ms" and then you can just update the value being sent without needing to take care of the TX rate. I'd have loved to see that instead of the complex filtering :) I know this is way too much for the generic kernel driver, though, so just a heads up of how this usually works.

Signature · 2 lines
Aleksander
https://aleksander.es
#9 lore raw
Quoted 9 lines · Aleksander Morgado
Quoted 5 lines · Marek Vasut
Quoted 5 lines
Quoted 5 lines

I was thinking about this and I mostly agree with you. Obviously, copying the code this way was dumb. On the other hand, ARINC and CAN are two different sort of busses, so I'd propose something slightly different here to avoid confusion and prevent the future extensions (or protocols) from adding unrelated cruft into the CAN stack.

I'd keep them separate not because ARINC may add unrelated cruft into the CAN stack, but because ARINC is much simpler than CAN already...

What about maintainability? Why take care of two almost identical subsystems? With making one stack "simpler" you increase, from my point of view, the costs of maintaining even more. If you fix problems in one stack you have to adopt the other, too.

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
#10 lore raw
Quoted 8 lines · Marc Kleine-Budde
Quoted 6 lines · Aleksander Morgado
Quoted 5 lines · Marek Vasut
Quoted 5 lines
Quoted 5 lines

I was thinking about this and I mostly agree with you. Obviously, copying the code this way was dumb. On the other hand, ARINC and CAN are two different sort of busses, so I'd propose something slightly different here to avoid confusion and prevent the future extensions (or protocols) from adding unrelated cruft into the CAN stack.

Quoted 7 lines
Quoted 2 lines

I'd keep them separate not because ARINC may add unrelated cruft into the CAN stack, but because ARINC is much simpler than CAN already...

What about maintainability? Why take care of two almost identical subsystems? With making one stack "simpler" you increase, from my point of view, the costs of maintaining even more. If you fix problems in one stack you have to adopt the other, too.

If they can share common code, that's fine, that probably can be worked around if needed. My main issues are actually with all the behavior that CAN supports and doesn't make much sense in ARINC, like the complex ID filtering scheme for example (ARINC just requires 256 bits for a minimum filter), or the duplex TX/RX setup for channels (channels are either RX or TX, not both), or the local echoing/loopback (which wouldn't make much sense for TX-only channels). The minimum subset of features required by an ARINC driver is actually very small. Trying to "fit" ARINC as a subset of CAN may actually be harder than keeping it separate maintainability wise. Maybe the issue here is that the original patch is too CAN-like while it shouldn't be, don't know.

Signature · 2 lines
Aleksander
https://aleksander.es
#11 lore raw
Quoted 10 lines · Aleksander Morgado
Quoted 4 lines

What about maintainability? Why take care of two almost identical subsystems? With making one stack "simpler" you increase, from my point of view, the costs of maintaining even more. If you fix problems in one stack you have to adopt the other, too.

If they can share common code, that's fine, that probably can be worked around if needed. My main issues are actually with all the behavior that CAN supports and doesn't make much sense in ARINC, like the complex ID filtering scheme for example (ARINC just requires 256 bits for a minimum filter),

I think it should be possible to use a simple/different filter mechanism for ARINC packages.

Quoted 4 lines

or the duplex TX/RX setup for channels
(channels are either RX or TX, not both), or the local echoing/loopback (which wouldn't make much sense for TX-only channels).

Local echo/loopback comes in two flavours:
- Other socket receive local generate frames, too.
This is interesting if you want to merge two ARINC node on single device.
- Sending socket receives send frame, too. This is useful if you need the feedback that the frame has _really_ been send, not just pushed into the networking stack.

Quoted 5 lines

The minimum subset of features required by an ARINC driver is actually very small. Trying to "fit" ARINC as a subset of CAN may actually be harder than keeping it separate maintainability wise. Maybe the issue here is that the original patch is too CAN-like while it shouldn't be, don't know.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
#12 lore raw
Quoted 9 lines
Quoted 4 lines

or the duplex TX/RX setup for channels
(channels are either RX or TX, not both), or the local echoing/loopback (which wouldn't make much sense for TX-only channels).

Local echo/loopback comes in two flavours:
- Other socket receive local generate frames, too.
This is interesting if you want to merge two ARINC node on single device.

I'd actually love having this for a simulator setup I use where I currently physically connect cables from a TX channel in one adapter to a RX channel in another adapter. But I'm not sure there's a specific real usecase for that apart from testing purposes.

Quoted 3 lines

- Sending socket receives send frame, too. This is useful if you need the feedback that the frame has _really_ been send, not just pushed into the networking stack.

I'd say that a TX error count could be enough here. I'm not sure if having the echo would justify making the TX channels also read-capable.

Remember that the actual hardware will have read-only or write-only channels itself. Each of the real hardware channels exposed in userspace as interfaces will therefore be read-only or write-only, and the user will need to know that before using them. An application wanting to read from channels will need to open and read from the RX channels only, an application wanting to write to the channels will need to open and write the TX channels only. The kernel should somehow specify the type for each of the channels, not to confuse the users. The virtual interface with both R/W caps doesn't really match what you would expect in a real interface.

Signature · 2 lines
Aleksander
https://aleksander.es
#13 lore raw
Quoted 10 lines · Aleksander Morgado
Quoted 9 lines
Quoted 4 lines

or the duplex TX/RX setup for channels
(channels are either RX or TX, not both), or the local echoing/loopback (which wouldn't make much sense for TX-only channels).

Local echo/loopback comes in two flavours:
- Other socket receive local generate frames, too.
This is interesting if you want to merge two ARINC node on single device.

Quoted 4 lines

I'd actually love having this for a simulator setup I use where I currently physically connect cables from a TX channel in one adapter to a RX channel in another adapter. But I'm not sure there's a specific real usecase for that apart from testing purposes.

Once you have ever used this functionalities you will start to think beyond.

It's a matter of (stress-)testing your applications after build on virtual CAN/ARINC interfaces. You will start to use the can-gw to route and/or modify frames between interfaces. You have all the tools to display/log/visualize and replay data. There's a wireshark plugin for PF_CAN you can easily adapt to present ARINC data, etc.

So when thinking about using PF_CAN as ARINC429 base ...

This is the CAN frame structure:

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/networking/can.txt?h=linux-4.2.y#n264

    struct can_frame {
            canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
            __u8    can_dlc; /* frame payload length in byte (0 .. 8) */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u8    data[8] __attribute__((aligned(8)));
    };

So what about defining an arinc429_frame like this:

    struct a429_frame {
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 3 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u8    data[8] __attribute__((aligned(8)));
    };

Don't know if your suggestion

+ * ARINC packet:
+ *
+ * .-.---.------.---.-----.
+ * |P|SSM| Data |SDI|Label|
+ * '-'---'------'---'-----'
+ * 3 3 2 2....1 1 9 8...0
+ * 1 0 9 8 1 0
+ */
+
+/**
+ * struct arinc429_frame - basic ARINC429 frame structure
+ * @label: ARINC429 label
+ * @data: ARINC429 P, SSM, DATA and SDI
+ */
+struct arinc429_frame {
+ __u8 label; /* 8 bit label */
+ __u8 data[3]; /* Up-to 23 bits are valid. */
+};

is really handy to use for arinc application programmers.

It looks like you need to shift the stuff in user space every time.

So you might better think of something like this:

    struct a429_frame {
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 8 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u32   data __attribute__((aligned(8)));
            __u8    p;       /* p */
            __u8    ssm;     /* ssm */
            __u8    sdi;     /* sdi */
            __u8    __end;   /* padding */
    };

Good thing would be that you can directly see the content in logfiles and you can easily modify the content on the fly by can-gw.

Of course the arinc netdevice driver would have to take care to do the correct rx/tx whatever. But routing and processing arinc content through the CAN stack does not seem to be a bad idea IMO.

Regards,
Oliver

#14 lore raw

On Tuesday, November 03, 2015 at 06:32:12 PM, Oliver Hartkopp wrote:

[...]

Quoted 4 lines

It looks like you need to shift the stuff in user space every time.

So you might better think of something like this:

Quoted 12 lines
    struct a429_frame {
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 8 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u32   data __attribute__((aligned(8)));
            __u8    p;       /* p */
            __u8    ssm;     /* ssm */
            __u8    sdi;     /* sdi */
            __u8    __end;   /* padding */
    };

You don't want to interpret those P(arity)/SSM/SDI bits, since they differ depending on whatever the remote party sends. That's why I decided to just make those into 3-bytes of data and let the userland application deal with it as seen fit. Besides, the ARINC "FTP" really uses those 3 bytes as plain data.

Quoted 6 lines

Good thing would be that you can directly see the content in logfiles and you can easily modify the content on the fly by can-gw.

Of course the arinc netdevice driver would have to take care to do the correct rx/tx whatever. But routing and processing arinc content through the CAN stack does not seem to be a bad idea IMO.

Pretty much, yeah.

Best regards,
Marek Vasut

#15 lore raw
Quoted 21 lines · Marek Vasut

On Tuesday, November 03, 2015 at 06:32:12 PM, Oliver Hartkopp wrote:

[...]

Quoted 4 lines

It looks like you need to shift the stuff in user space every time.

So you might better think of something like this:

Quoted 12 lines
    struct a429_frame {
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 8 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u32   data __attribute__((aligned(8)));
            __u8    p;       /* p */
            __u8    ssm;     /* ssm */
            __u8    sdi;     /* sdi */
            __u8    __end;   /* padding */
    };
Quoted 5 lines

You don't want to interpret those P(arity)/SSM/SDI bits, since they differ depending on whatever the remote party sends. That's why I decided to just make those into 3-bytes of data and let the userland application deal with it as seen fit. Besides, the ARINC "FTP" really uses those 3 bytes as plain data.

Ok. I did not know what P was for :-)

Btw. it can make sense to introduce an union struct where different options to access the content are possible.

E.g. you might have a 32 bit word, some bit-wise specification and a four byte tuple to access the three bytes for ARINC FTP ...

Regards,
Oliver

#16 lore raw
Quoted 23 lines · Oliver Hartkopp
Quoted 22 lines · Marek Vasut

On Tuesday, November 03, 2015 at 06:32:12 PM, Oliver Hartkopp wrote:

[...]

Quoted 17 lines

It looks like you need to shift the stuff in user space every time.

So you might better think of something like this:

    struct a429_frame {
    
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 8 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u32   data __attribute__((aligned(8)));
            __u8    p;       /* p */
            __u8    ssm;     /* ssm */
            __u8    sdi;     /* sdi */
            __u8    __end;   /* padding */
    
    };
Quoted 7 lines
Quoted 5 lines

You don't want to interpret those P(arity)/SSM/SDI bits, since they differ depending on whatever the remote party sends. That's why I decided to just make those into 3-bytes of data and let the userland application deal with it as seen fit. Besides, the ARINC "FTP" really uses those 3 bytes as plain data.

Ok. I did not know what P was for :-)

Oh yeah. P is parity and it's optional as well and can be odd/even depending on the remote endpoint (sigh).

Quoted 2 lines

Btw. it can make sense to introduce an union struct where different options to access the content are possible.

This would be pretty nasty I think. By reading the ARINC specification, the SSM can be either 2 or 3 bits, the SDI is who-knows-what depending on the remote endpoint and the P is also not always present. I'm not convinced that the kernel should interpret the 3 byte ARINC payload in any way. (but I wonder if my argument presented above is convincing at all either ...).

So while we can do it for the common case, I wonder if this isn't overengineering things a bit right from the beginning. Wouldn't it make more sense to add this only once the need for it is there? Such change won't create an incompatible change to the ABI, so from my perspective, postponing it won't hurt.

Quoted 2 lines

E.g. you might have a 32 bit word, some bit-wise specification and a four byte tuple to access the three bytes for ARINC FTP ...

I understand the idea, yes.

Best regards,
Marek Vasut

#17 lore raw
Quoted 35 lines · Marek Vasut
Quoted 23 lines · Oliver Hartkopp
Quoted 22 lines · Marek Vasut

On Tuesday, November 03, 2015 at 06:32:12 PM, Oliver Hartkopp wrote:

[...]

Quoted 17 lines

It looks like you need to shift the stuff in user space every time.

So you might better think of something like this:

    struct a429_frame {
    
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 8 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u32   data __attribute__((aligned(8)));
            __u8    p;       /* p */
            __u8    ssm;     /* ssm */
            __u8    sdi;     /* sdi */
            __u8    __end;   /* padding */
    
    };
Quoted 7 lines
Quoted 5 lines

You don't want to interpret those P(arity)/SSM/SDI bits, since they differ depending on whatever the remote party sends. That's why I decided to just make those into 3-bytes of data and let the userland application deal with it as seen fit. Besides, the ARINC "FTP" really uses those 3 bytes as plain data.

Ok. I did not know what P was for :-)

Oh yeah. P is parity and it's optional as well and can be odd/even depending on the remote endpoint (sigh).

Quoted 8 lines
Quoted 2 lines

Btw. it can make sense to introduce an union struct where different options to access the content are possible.

This would be pretty nasty I think. By reading the ARINC specification, the SSM can be either 2 or 3 bits, the SDI is who-knows-what depending on the remote endpoint and the P is also not always present. I'm not convinced that the kernel should interpret the 3 byte ARINC payload in any way. (but I wonder if my argument presented above is convincing at all either ...).

Right.

When we define a user visible data structure, this is written into stone.

When ARINC isn't even sure about the detailed interpretation we should definitely keep our fingers away from doing it ourselves.

Best regards,
Oliver

#18 lore raw
Quoted 46 lines · Oliver Hartkopp
Quoted 38 lines · Marek Vasut
Quoted 23 lines · Oliver Hartkopp
Quoted 22 lines · Marek Vasut

On Tuesday, November 03, 2015 at 06:32:12 PM, Oliver Hartkopp wrote:

[...]

Quoted 17 lines

It looks like you need to shift the stuff in user space every time.

So you might better think of something like this:

    struct a429_frame {
    
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 8 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u32   data __attribute__((aligned(8)));
            __u8    p;       /* p */
            __u8    ssm;     /* ssm */
            __u8    sdi;     /* sdi */
            __u8    __end;   /* padding */
    
    };
Quoted 7 lines
Quoted 5 lines

You don't want to interpret those P(arity)/SSM/SDI bits, since they differ depending on whatever the remote party sends. That's why I decided to just make those into 3-bytes of data and let the userland application deal with it as seen fit. Besides, the ARINC "FTP" really uses those 3 bytes as plain data.

Ok. I did not know what P was for :-)

Oh yeah. P is parity and it's optional as well and can be odd/even depending on the remote endpoint (sigh).

Quoted 2 lines

Btw. it can make sense to introduce an union struct where different options to access the content are possible.

Quoted 6 lines

This would be pretty nasty I think. By reading the ARINC specification, the SSM can be either 2 or 3 bits, the SDI is who-knows-what depending on the remote endpoint and the P is also not always present. I'm not convinced that the kernel should interpret the 3 byte ARINC payload in any way. (but I wonder if my argument presented above is convincing at all either ...).

Quoted 6 lines

Right.

When we define a user visible data structure, this is written into stone.

When ARINC isn't even sure about the detailed interpretation we should definitely keep our fingers away from doing it ourselves.

Right. Besides, such extension to the ABI can be done later if the need arises (which I seriously doubt), can't it ? Handling the payload as a CAN payload makes sense.

Best regards,
Marek Vasut

#19 lore raw
Quoted 49 lines · Marek Vasut
Quoted 48 lines · Oliver Hartkopp
Quoted 38 lines · Marek Vasut
Quoted 23 lines · Oliver Hartkopp
Quoted 22 lines · Marek Vasut

On Tuesday, November 03, 2015 at 06:32:12 PM, Oliver Hartkopp wrote:

[...]

Quoted 17 lines

It looks like you need to shift the stuff in user space every time.

So you might better think of something like this:

    struct a429_frame {

            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 8 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u32   data __attribute__((aligned(8)));
            __u8    p;       /* p */
            __u8    ssm;     /* ssm */
            __u8    sdi;     /* sdi */
            __u8    __end;   /* padding */

    };
Quoted 7 lines
Quoted 5 lines

You don't want to interpret those P(arity)/SSM/SDI bits, since they differ depending on whatever the remote party sends. That's why I decided to just make those into 3-bytes of data and let the userland application deal with it as seen fit. Besides, the ARINC "FTP" really uses those 3 bytes as plain data.

Ok. I did not know what P was for :-)

Oh yeah. P is parity and it's optional as well and can be odd/even depending on the remote endpoint (sigh).

Quoted 2 lines

Btw. it can make sense to introduce an union struct where different options to access the content are possible.

Quoted 6 lines

This would be pretty nasty I think. By reading the ARINC specification, the SSM can be either 2 or 3 bits, the SDI is who-knows-what depending on the remote endpoint and the P is also not always present. I'm not convinced that the kernel should interpret the 3 byte ARINC payload in any way. (but I wonder if my argument presented above is convincing at all either ...).

Right.

Quoted 8 lines
Quoted 4 lines

When we define a user visible data structure, this is written into stone.

When ARINC isn't even sure about the detailed interpretation we should definitely keep our fingers away from doing it ourselves.

Right. Besides, such extension to the ABI can be done later if the need arises (which I seriously doubt), can't it ? Handling the payload as a CAN payload makes sense.

Agree on this, the three non-label bytes in an ARINC word should be taken as opaque payload. The only exception would be the parity most significant bit, but I don't think it'd be an issue to have that in the opaque payload.

Signature · 2 lines
Aleksander
https://aleksander.es
#20 lore raw
Quoted 56 lines · Aleksander Morgado
Quoted 55 lines · Marek Vasut
Quoted 53 lines · Oliver Hartkopp
Quoted 38 lines · Marek Vasut
Quoted 23 lines · Oliver Hartkopp
Quoted 22 lines · Marek Vasut

On Tuesday, November 03, 2015 at 06:32:12 PM, Oliver Hartkopp wrote:

[...]

Quoted 17 lines

It looks like you need to shift the stuff in user space every time.

So you might better think of something like this:

    struct a429_frame {
    
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 8 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u32   data __attribute__((aligned(8)));
            __u8    p;       /* p */
            __u8    ssm;     /* ssm */
            __u8    sdi;     /* sdi */
            __u8    __end;   /* padding */
    
    };
Quoted 7 lines
Quoted 5 lines

You don't want to interpret those P(arity)/SSM/SDI bits, since they differ depending on whatever the remote party sends. That's why I decided to just make those into 3-bytes of data and let the userland application deal with it as seen fit. Besides, the ARINC "FTP" really uses those 3 bytes as plain data.

Ok. I did not know what P was for :-)

Oh yeah. P is parity and it's optional as well and can be odd/even depending on the remote endpoint (sigh).

Quoted 2 lines

Btw. it can make sense to introduce an union struct where different options to access the content are possible.

Quoted 6 lines

This would be pretty nasty I think. By reading the ARINC specification, the SSM can be either 2 or 3 bits, the SDI is who-knows-what depending on the remote endpoint and the P is also not always present. I'm not convinced that the kernel should interpret the 3 byte ARINC payload in any way. (but I wonder if my argument presented above is convincing at all either ...).

Right.

When we define a user visible data structure, this is written into stone.

When ARINC isn't even sure about the detailed interpretation we should definitely keep our fingers away from doing it ourselves.

Quoted 8 lines
Quoted 3 lines

Right. Besides, such extension to the ABI can be done later if the need arises (which I seriously doubt), can't it ? Handling the payload as a CAN payload makes sense.

Agree on this, the three non-label bytes in an ARINC word should be taken as opaque payload. The only exception would be the parity most significant bit, but I don't think it'd be an issue to have that in the opaque payload.

About the parity -- can we add some flag into the datagram to indicate we want hardware to calculate the parity for that particular datagram for us? And we'd also need to indicate what type of parity. I dunno if this is worth the hassle.

Best regards,
Marek Vasut

#21 lore raw

Hi, Marek.

Quoted 4 lines

About the parity -- can we add some flag into the datagram to indicate we want hardware to calculate the parity for that particular datagram for us? And we'd also need to indicate what type of parity. I dunno if this is worth the hassle.

This is HW configuration property, it does not belong to datagram. Also for TX channels, parity could be two kinds: odd and even, for RX it is only on/off.

Parity is not the only property that needs to be configured in HW, following could be needed as well,
- label bit flipping (on or off)
- rate change (low / high)
- label filters and label priority matching (this could be HoltIC specific)

I suppose all these properties are configured only once, at interface initialization.

Signature · 2 lines
Best regards,
Andrey Vostrikov
#22 lore raw
Quoted 1 line · Vostrikov Andrey

Hi, Marek.

Hi,

Quoted 8 lines
Quoted 4 lines

About the parity -- can we add some flag into the datagram to indicate we want hardware to calculate the parity for that particular datagram for us? And we'd also need to indicate what type of parity. I dunno if this is worth the hassle.

This is HW configuration property, it does not belong to datagram. Also for TX channels, parity could be two kinds: odd and even, for RX it is only on/off.

There are datagrams which do contain parity and ones which do not contain it, correct ? Thus, it's a property of that particular datagram.

Quoted 3 lines

Parity is not the only property that needs to be configured in HW, following could be needed as well,
- label bit flipping (on or off)

This is hardware property.

Quoted 1 line

- rate change (low / high)

This is again hardware configuration -- you have to configure the link speed before you do RX/TX.

Quoted 5 lines

- label filters and label priority matching (this could be HoltIC specific)

I suppose all these properties are configured only once, at interface initialization.

These three above, yes. Parity, I don't think so.

Best regards,
Marek Vasut

#23 lore raw

Hi, Marek.

Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

About the parity -- can we add some flag into the datagram to indicate we want hardware to calculate the parity for that particular datagram for us? And we'd also need to indicate what type of parity. I dunno if this is worth the hassle.

This is HW configuration property, it does not belong to datagram. Also for TX channels, parity could be two kinds: odd and even, for RX it is only on/off.

There are datagrams which do contain parity and ones which do not contain it, correct ? Thus, it's a property of that particular datagram.

For RX side it is both: datagram and HW (is it checked by receiver or not)
But for TX side it is HW property of transmitter, either OFF or ON (odd or even).

Signature · 2 lines
Best regards,
Andrey Vostrikov
#24 lore raw
Quoted 11 lines · Vostrikov Andrey
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

About the parity -- can we add some flag into the datagram to indicate we want hardware to calculate the parity for that particular datagram for us? And we'd also need to indicate what type of parity. I dunno if this is worth the hassle.

This is HW configuration property, it does not belong to datagram. Also for TX channels, parity could be two kinds: odd and even, for RX it is only on/off.

There are datagrams which do contain parity and ones which do not contain it, correct ? Thus, it's a property of that particular datagram.

All ARINC words have bit #31 as parity bit; whether it's used or not depends on the setup as Andrey says below.

Quoted 2 lines

For RX side it is both: datagram and HW (is it checked by receiver or not)
But for TX side it is HW property of transmitter, either OFF or ON (odd or even).

Signature · 2 lines
Aleksander
https://aleksander.es
#25 lore raw
Quoted 12 lines · Aleksander Morgado

On Wed, Nov 4, 2015 at 4:18 PM, Vostrikov Andrey

Quoted 9 lines · <[email protected]> wrote:
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

About the parity -- can we add some flag into the datagram to indicate we want hardware to calculate the parity for that particular datagram for us? And we'd also need to indicate what type of parity. I dunno if this is worth the hassle.

This is HW configuration property, it does not belong to datagram. Also for TX channels, parity could be two kinds: odd and even, for RX it is only on/off.

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

There are datagrams which do contain parity and ones which do not contain it, correct ? Thus, it's a property of that particular datagram.

All ARINC words have bit #31 as parity bit; whether it's used or not depends on the setup as Andrey says below.

Can bit 31 be ever used for DATA instead of parity ? Or is this just me not understanding the parlance of the specification, where "DATA" actually means "DATA with parity" ?

Best regards,
Marek Vasut

#26 lore raw
Quoted 17 lines · Marek Vasut
Quoted 16 lines · Aleksander Morgado

On Wed, Nov 4, 2015 at 4:18 PM, Vostrikov Andrey

Quoted 12 lines · <[email protected]> wrote:
Quoted 12 lines
Quoted 8 lines
Quoted 4 lines

About the parity -- can we add some flag into the datagram to indicate we want hardware to calculate the parity for that particular datagram for us? And we'd also need to indicate what type of parity. I dunno if this is worth the hassle.

This is HW configuration property, it does not belong to datagram. Also for TX channels, parity could be two kinds: odd and even, for RX it is only on/off.

There are datagrams which do contain parity and ones which do not contain it, correct ? Thus, it's a property of that particular datagram.

Quoted 6 lines
Quoted 2 lines

All ARINC words have bit #31 as parity bit; whether it's used or not depends on the setup as Andrey says below.

Can bit 31 be ever used for DATA instead of parity ? Or is this just me not understanding the parlance of the specification, where "DATA" actually means "DATA with parity" ?

Well, as far as I know bit 31 is always parity bit, never used for actual data contents. Which is the spec section that got you confused? Maybe I'm the one which didn't read it well?

Signature · 2 lines
Aleksander
https://aleksander.es
#27 lore raw
Quoted 21 lines · Aleksander Morgado
Quoted 20 lines · Marek Vasut
Quoted 18 lines · Aleksander Morgado

On Wed, Nov 4, 2015 at 4:18 PM, Vostrikov Andrey

Quoted 5 lines · <[email protected]> wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

About the parity -- can we add some flag into the datagram to indicate we want hardware to calculate the parity for that particular datagram for us? And we'd also need to indicate what type of parity. I dunno if this is worth the hassle.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

This is HW configuration property, it does not belong to datagram. Also for TX channels, parity could be two kinds: odd and even, for RX it is only on/off.

There are datagrams which do contain parity and ones which do not contain it, correct ? Thus, it's a property of that particular datagram.

All ARINC words have bit #31 as parity bit; whether it's used or not depends on the setup as Andrey says below.

Quoted 7 lines
Quoted 3 lines

Can bit 31 be ever used for DATA instead of parity ? Or is this just me not understanding the parlance of the specification, where "DATA" actually means "DATA with parity" ?

Well, as far as I know bit 31 is always parity bit, never used for actual data contents. Which is the spec section that got you confused? Maybe I'm the one which didn't read it well?

Sorry for being so late into the discussion.

I got confused by hi-3585_v-rev-l.pdf page 7 right, CR4 lets you treat bit 32 as either data or parity. But I guess this is not the general case.

So I wonder, does it make sense to treat the P bit as data always and do parity in software or not ?

Best regards,
Marek Vasut

#28 lore raw
Quoted 24 lines · Marek Vasut
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

About the parity -- can we add some flag into the datagram to indicate we want hardware to calculate the parity for that particular datagram for us? And we'd also need to indicate what type of parity. I dunno if this is worth the hassle.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

This is HW configuration property, it does not belong to datagram. Also for TX channels, parity could be two kinds: odd and even, for RX it is only on/off.

There are datagrams which do contain parity and ones which do not contain it, correct ? Thus, it's a property of that particular datagram.

All ARINC words have bit #31 as parity bit; whether it's used or not depends on the setup as Andrey says below.

Quoted 7 lines
Quoted 3 lines

Can bit 31 be ever used for DATA instead of parity ? Or is this just me not understanding the parlance of the specification, where "DATA" actually means "DATA with parity" ?

Well, as far as I know bit 31 is always parity bit, never used for actual data contents. Which is the spec section that got you confused? Maybe I'm the one which didn't read it well?

Quoted 7 lines

Sorry for being so late into the discussion.

I got confused by hi-3585_v-rev-l.pdf page 7 right, CR4 lets you treat bit 32 as either data or parity. But I guess this is not the general case.

So I wonder, does it make sense to treat the P bit as data always and do parity in software or not ?

I don't have an strong opinion on this, truth be told. It really depends on whether we can tell the HW "go compute the parity yourself". If we can ask for that, maybe we should allow configuring that in the API with some flag. But anyway, treating P as data (i.e. software should set parity bit to whatever is needed) is the most generic thing you could do for a start, that shouldn't be wrong.

Signature · 2 lines
Aleksander
https://aleksander.es
#29 lore raw
Quoted 34 lines · Aleksander Morgado
Quoted 24 lines · Marek Vasut
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

About the parity -- can we add some flag into the datagram to indicate we want hardware to calculate the parity for that particular datagram for us? And we'd also need to indicate what type of parity. I dunno if this is worth the hassle.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

This is HW configuration property, it does not belong to datagram. Also for TX channels, parity could be two kinds:
odd and even, for RX it is only on/off.

There are datagrams which do contain parity and ones which do not contain it, correct ? Thus, it's a property of that particular datagram.

All ARINC words have bit #31 as parity bit; whether it's used or not depends on the setup as Andrey says below.

Quoted 7 lines
Quoted 3 lines

Can bit 31 be ever used for DATA instead of parity ? Or is this just me not understanding the parlance of the specification, where "DATA" actually means "DATA with parity" ?

Well, as far as I know bit 31 is always parity bit, never used for actual data contents. Which is the spec section that got you confused? Maybe I'm the one which didn't read it well?

Quoted 8 lines

Sorry for being so late into the discussion.

I got confused by hi-3585_v-rev-l.pdf page 7 right, CR4 lets you treat bit 32 as either data or parity. But I guess this is not the general case.

So I wonder, does it make sense to treat the P bit as data always and do parity in software or not ?

Quoted 6 lines

I don't have an strong opinion on this, truth be told. It really depends on whether we can tell the HW "go compute the parity yourself". If we can ask for that, maybe we should allow configuring that in the API with some flag. But anyway, treating P as data (i.e. software should set parity bit to whatever is needed) is the most generic thing you could do for a start, that shouldn't be wrong.

OK, let's treat it as data.

Since RC1 is out, I should start reworking the framework into more sensible shape and repost before I miss the opportunity.

Best regards,
Marek Vasut

#30 lore raw
In reply to Oliver Hartkopp

Hi, Oliver.

Quoted 18 lines

So when thinking about using PF_CAN as ARINC429 base ...

This is the CAN frame structure:

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/networking/can.txt?h=linux-4.2.y#n264

    struct can_frame {
            canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
            __u8    can_dlc; /* frame payload length in byte (0 .. 8) */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u8    data[8] __attribute__((aligned(8)));
    };

So what about defining an arinc429_frame like this:

Quoted 8 lines
    struct a429_frame {
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 3 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u8    data[8] __attribute__((aligned(8)));
    };

What would be the benefit besides reusing CAN tools to have arinc429 frame structure four times larger that it needs to be?

It just adds complexity to implement translation in device driver from can-like structures to native 4-bytes message. Similar translation will be needed in application as well.

There is no real processing needed for ARINC429 frames inside
framework. Almost all features are done by HW itself (label filters,
label priority matching, label bit flipping, rate selection, parity
and sdi decoding) or by application.

I'd prefer to have ARINC framework simple as it could be and separate from CAN, as these buses are not similar, besides desire to re-use SocketCAN interface/API to expose ARINC429 bus.

--
Best regards,
Andrey Vostrikov

#31 lore raw

Hi Andrey,

Quoted 28 lines · Vostrikov Andrey

Hi, Oliver.

Quoted 18 lines

So when thinking about using PF_CAN as ARINC429 base ...

This is the CAN frame structure:

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/networking/can.txt?h=linux-4.2.y#n264

    struct can_frame {
            canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
            __u8    can_dlc; /* frame payload length in byte (0 .. 8) */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u8    data[8] __attribute__((aligned(8)));
    };

So what about defining an arinc429_frame like this:

Quoted 8 lines
    struct a429_frame {
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 3 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u8    data[8] __attribute__((aligned(8)));
    };
Quoted 2 lines

What would be the benefit besides reusing CAN tools to have arinc429 frame structure four times larger that it needs to be?

Comparing to typical ethernet frames with 1500 bytes the 16 bytes for CAN frames or 72 bytes for CAN FD frames are already too small in relation to the socket buffer overhead.

If you want to improve the memory efficiency for arinc290 you should probably consider to implement a character device based driver instead of creating a new network protocol family.

Quoted 3 lines

It just adds complexity to implement translation in device driver from can-like structures to native 4-bytes message. Similar translation will be needed in application as well.

That's BS. You put the data into a struct a429_frame at driver level and you read the data from struct a429_frame on application level.

Where is the 'translation'?

You would need to do the same with every other data structure in the world too.

Quoted 6 lines

There is no real processing needed for ARINC429 frames inside
framework. Almost all features are done by HW itself (label filters,
label priority matching, label bit flipping, rate selection, parity
and sdi decoding) or by application.

From what I've read so far there's also the sending of cyclic messages and

label filtering outside the HW - or why did you copy/paste the can_id/label filter mechanism from af_can.c ?

Quoted 5 lines

I'd prefer to have ARINC framework simple as it could be and separate from CAN, as these buses are not similar, besides desire to re-use SocketCAN interface/API to expose ARINC429 bus.

From what I've seen so far the ARINC429 requirements can be handled with the

PF_CAN infrastructure only by defining a matching data structure and by adding some arinc device specific configuration interface.

The latter is probably completely independent from the current CAN netlink interface for configuration.

But the suggested arinc429 stuff for the network layer looks just like a needless code duplication.
Maybe you don't need that fancy stuff that comes with PF_CAN. Did you ever thought about implementing a chardev driver for the ARINC429 hardware? There are out-of-tree CAN drivers (e.g. can4linux or PEAK System Linux driver) that handle the transfer of data structures (CAN frames) from/to kernel space via character device. See an example at https://en.wikipedia.org/wiki/Can4linux

Best regards,
Oliver

#32 lore raw
Quoted 38 lines · Oliver Hartkopp

Hi Andrey,

Quoted 30 lines · Vostrikov Andrey

Hi, Oliver.

Quoted 28 lines

So when thinking about using PF_CAN as ARINC429 base ...

This is the CAN frame structure:

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tre
e/Documentation/networking/can.txt?h=linux-4.2.y#n264

    struct can_frame {
    
            canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
            __u8    can_dlc; /* frame payload length in byte (0 .. 8) */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u8    data[8] __attribute__((aligned(8)));
    
    };

So what about defining an arinc429_frame like this:

    struct a429_frame {
    
            __u32   label;   /* ARINC 429 label */
            __u8    length;  /* always set to 3 */
            __u8    __pad;   /* padding */
            __u8    __res0;  /* reserved / padding */
            __u8    __res1;  /* reserved / padding */
            __u8    data[8] __attribute__((aligned(8)));
Quoted 4 lines
Quoted 1 line
    };

What would be the benefit besides reusing CAN tools to have arinc429 frame structure four times larger that it needs to be?

Quoted 7 lines

Comparing to typical ethernet frames with 1500 bytes the 16 bytes for CAN frames or 72 bytes for CAN FD frames are already too small in relation to the socket buffer overhead.

If you want to improve the memory efficiency for arinc290 you should probably consider to implement a character device based driver instead of creating a new network protocol family.

See discussion:

http://comments.gmane.org/gmane.linux.kernel/1512019

Which is why I picked the socket variant.

Quoted 12 lines
Quoted 3 lines

It just adds complexity to implement translation in device driver from can-like structures to native 4-bytes message. Similar translation will be needed in application as well.

That's BS. You put the data into a struct a429_frame at driver level and you read the data from struct a429_frame on application level.

Where is the 'translation'?

You would need to do the same with every other data structure in the world too.

Quoted 8 lines
Quoted 4 lines
There   is   no   real   processing  needed for ARINC429 frames inside
framework. Almost all features  are  done  by  HW  itself  (label 
filters, label  priority matching,   label   bit  flipping,  rate 

selection, parity and sdi decoding) or by application.

From what I've read so far there's also the sending of cyclic messages and label filtering outside the HW - or why did you copy/paste the can_id/label filter mechanism from af_can.c ?

I think you might be mixing two people together here, I sent the patch and Andrey and Aleksander are working for some other interested company.

The label filtering makes sense if you want to separate what you receive on which socket in userland, which allows an application to receive only relevant traffic.

Hardware-accelerated filtering is another thing and at this point, we should not mix these two things. Does CAN framework have any such support for hardware assisted can_id filtering btw ?

Quoted 10 lines
Quoted 3 lines

I'd prefer to have ARINC framework simple as it could be and separate from CAN, as these buses are not similar, besides desire to re-use SocketCAN interface/API to expose ARINC429 bus.

From what I've seen so far the ARINC429 requirements can be handled with the PF_CAN infrastructure only by defining a matching data structure and by adding some arinc device specific configuration interface.

The latter is probably completely independent from the current CAN netlink interface for configuration.

Right.

Quoted 2 lines

But the suggested arinc429 stuff for the network layer looks just like a needless code duplication.

Yes.

Quoted 6 lines

Maybe you don't need that fancy stuff that comes with PF_CAN. Did you ever thought about implementing a chardev driver for the ARINC429 hardware? There are out-of-tree CAN drivers (e.g. can4linux or PEAK System Linux driver) that handle the transfer of data structures (CAN frames) from/to kernel space via character device. See an example at
https://en.wikipedia.org/wiki/Can4linux

I guess I can answer that -- yes, I did, see above.

#33 lore raw

Hi Marek,

Quoted 11 lines · Marek Vasut
Quoted 7 lines · Oliver Hartkopp

Comparing to typical ethernet frames with 1500 bytes the 16 bytes for CAN frames or 72 bytes for CAN FD frames are already too small in relation to the socket buffer overhead.

If you want to improve the memory efficiency for arinc290 you should probably consider to implement a character device based driver instead of creating a new network protocol family.

Quoted 6 lines

See discussion:

http://comments.gmane.org/gmane.linux.kernel/1512019

Which is why I picked the socket variant.

Oh. This provides a completely new perspective.

So far we just discussed about the 32 bit messages to be handled and filtered by the kernel.

This could have been done by

1. A chardev interface driver

2. A netdev interface driver (drivers/net/arinc429/...) and using PF_PACKET together with Berkley packet filtering (BPF)

3. A netdev interface driver (drivers/net/arinc429/...) and using PF_CAN which would lead to a arinc data structure which needs to be struct can_frame compatible.

But if you plan to implement the transport protocols (FTP/MAC) inside the Linux kernel that have been discussed in the URL above this would be a real difference to CAN related protocols. Only from that perspective a new protocol family would make sense.

(..)

Quoted 6 lines
Quoted 3 lines

From what I've read so far there's also the sending of cyclic messages and
label filtering outside the HW - or why did you copy/paste the can_id/label filter mechanism from af_can.c ?

I think you might be mixing two people together here, I sent the patch and Andrey and Aleksander are working for some other interested company.

Sorry. Will try to bash only *you* in the future :-))

Quoted 3 lines

The label filtering makes sense if you want to separate what you receive on which socket in userland, which allows an application to receive only relevant traffic.

ok.

Quoted 5 lines

Hardware-accelerated filtering is another thing and at this point, we should not mix these two things. Does CAN framework have any such support for hardware assisted can_id filtering btw ?

No. We discussed about it. But the HW filter capabilities of CAN controllers have a wide range of functionality. Most filters make only sense in ECUs that pick specific CAN IDs for their functionality. It made no real sense to have an administrative configuration interface that limits the view to the CAN bus for the entire system. An we never had performance issues with the filtering in the softirq context in af_can.c

Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

I'd prefer to have ARINC framework simple as it could be and separate from CAN, as these buses are not similar, besides desire to re-use SocketCAN interface/API to expose ARINC429 bus.

Quoted 9 lines
Quoted 6 lines

Maybe you don't need that fancy stuff that comes with PF_CAN. Did you ever thought about implementing a chardev driver for the ARINC429 hardware? There are out-of-tree CAN drivers (e.g. can4linux or PEAK System Linux driver) that handle the transfer of data structures (CAN frames) from/to kernel space via character device. See an example at
https://en.wikipedia.org/wiki/Can4linux

I guess I can answer that -- yes, I did, see above.

Ok - it seems to stick on the future plan whether it makes sense to implement the FTP/MAC transport protocols inside the kernel or not.

What's your thought about that?

Regards,
Oliver

#34 lore raw
In reply to Oliver Hartkopp

Hi, Oliver.

Quoted 3 lines

Comparing to typical ethernet frames with 1500 bytes the 16 bytes for CAN frames or 72 bytes for CAN FD frames are already too small in relation to the socket buffer overhead.

Ok, if there is no big difference using 4-bytes structure or 16-bytes structures, I do not have any objections.

Quoted 3 lines

If you want to improve the memory efficiency for arinc290 you should probably consider to implement a character device based driver instead of creating a new network protocol family.

I suppose such drivers have been implemented before, but by some reasons socket API is preferred now. I do not have any details regarding this.

Quoted 8 lines
Quoted 3 lines

It just adds complexity to implement translation in device driver from can-like structures to native 4-bytes message. Similar translation will be needed in application as well.

That's BS. You put the data into a struct a429_frame at driver level and you read the data from struct a429_frame on application level.

Where is the 'translation'?

Ok, I overreacted a bit. Even in current proposal it is needed to move bytes in HI-3593 driver as well, as this chip accepts label as last byte, instead of first one in SPI transfers. It was just a wish to use same data without any actions when moving it between framework and HW.

Quoted 3 lines

From what I've read so far there's also the sending of cyclic messages and label filtering outside the HW - or why did you copy/paste the can_id/label filter mechanism from af_can.c ?

It is not I who copied CAN code, and I do not think that CAN label filter mechanism fits ARINC, as it looks overcomplicated for small label space in ARINC429

Signature · 2 lines
Best regards,
Andrey Vostrikov
#35 lore raw
In reply to Aleksander Morgado
Quoted 17 lines · Aleksander Morgado
Quoted 8 lines · Marc Kleine-Budde
Quoted 7 lines · Aleksander Morgado
Quoted 5 lines · Marek Vasut
Quoted 5 lines
Quoted 5 lines

I was thinking about this and I mostly agree with you. Obviously, copying the code this way was dumb. On the other hand, ARINC and CAN are two different sort of busses, so I'd propose something slightly different here to avoid confusion and prevent the future extensions (or protocols) from adding unrelated cruft into the CAN stack.

Quoted 7 lines
Quoted 2 lines

I'd keep them separate not because ARINC may add unrelated cruft into the CAN stack, but because ARINC is much simpler than CAN already...

What about maintainability? Why take care of two almost identical subsystems? With making one stack "simpler" you increase, from my point of view, the costs of maintaining even more. If you fix problems in one stack you have to adopt the other, too.

Quoted 5 lines

If they can share common code, that's fine, that probably can be worked around if needed. My main issues are actually with all the behavior that CAN supports and doesn't make much sense in ARINC, like the complex ID filtering scheme for example (ARINC just requires 256 bits for a minimum filter)

So does CAN, I don't see a problem re-using the filtering infrastructure here.

Quoted 4 lines

, or the duplex TX/RX setup for channels
(channels are either RX or TX, not both), or the local echoing/loopback (which wouldn't make much sense for TX-only channels).

Aren't the RX-only/TX-only channels rather a special case ? In that case, you can register a device per each such channel and be done with it, no ?

Quoted 5 lines

The minimum subset of features required by an ARINC driver is actually very small. Trying to "fit" ARINC as a subset of CAN may actually be harder than keeping it separate maintainability wise. Maybe the issue here is that the original patch is too CAN-like while it shouldn't be, don't know.

Best regards,
Marek Vasut

#36 lore raw
Quoted 6 lines · Marek Vasut
Quoted 4 lines

, or the duplex TX/RX setup for channels
(channels are either RX or TX, not both), or the local echoing/loopback (which wouldn't make much sense for TX-only channels).

Aren't the RX-only/TX-only channels rather a special case ?

They're actually the only case AFAIK. You've got systems generating streams of ARINC429 words (e.g. the IRS, the FMC...) and systems that may consume the streams from multiple independent channels (e.g. the IFE). I try to think of each logical bus as a single transmitter broadcasting to multiple receivers.

Signature · 2 lines
Aleksander
https://aleksander.es
#37 lore raw
Quoted 6 lines · Aleksander Morgado
Quoted 5 lines · Marek Vasut
Quoted 4 lines

, or the duplex TX/RX setup for channels
(channels are either RX or TX, not both), or the local echoing/loopback (which wouldn't make much sense for TX-only channels).

Quoted 7 lines
Quoted 1 line

Aren't the RX-only/TX-only channels rather a special case ?

They're actually the only case AFAIK. You've got systems generating streams of ARINC429 words (e.g. the IRS, the FMC...) and systems that may consume the streams from multiple independent channels (e.g. the IFE). I try to think of each logical bus as a single transmitter broadcasting to multiple receivers.

I've re-checked the spec and it does say that there may be systems that act as source (TX) and sink (RX), e.g. DME, VOR or ILS. But in those cases, they will actually have separate TX and RX physical ports.

Signature · 2 lines
Aleksander
https://aleksander.es
#38 lore raw
Quoted 17 lines · Aleksander Morgado

On Tue, Nov 3, 2015 at 5:18 PM, Aleksander Morgado

Quoted 6 lines · <[email protected]> wrote:
Quoted 5 lines · Marek Vasut
Quoted 4 lines

, or the duplex TX/RX setup for channels
(channels are either RX or TX, not both), or the local echoing/loopback (which wouldn't make much sense for TX-only channels).

Quoted 7 lines
Quoted 1 line

Aren't the RX-only/TX-only channels rather a special case ?

They're actually the only case AFAIK. You've got systems generating streams of ARINC429 words (e.g. the IRS, the FMC...) and systems that may consume the streams from multiple independent channels (e.g. the IFE). I try to think of each logical bus as a single transmitter broadcasting to multiple receivers.

Quoted 4 lines

I've re-checked the spec and it does say that there may be systems that act as source (TX) and sink (RX), e.g. DME, VOR or ILS. But in those cases, they will actually have separate TX and RX physical ports.

So, considering that hi3593 which as 2x RX and 1x TX port, what about registering one device per port and be done with it ?

Best regards,
Marek Vasut

#39 lore raw

Hi, Marek.

Quoted 2 lines

So, considering that hi3593 which as 2x RX and 1x TX port, what about registering one device per port and be done with it ?

Yes, that is fine. It could be easily done. Just drop tx requests on rx channel and vice versa.

Signature · 2 lines
Best regards,
Andrey Vostrikov
#40 lore raw
In reply to Marek Vasut
Quoted 18 lines · Marek Vasut
Quoted 17 lines · Aleksander Morgado

On Tue, Nov 3, 2015 at 5:18 PM, Aleksander Morgado

Quoted 13 lines · <[email protected]> wrote:
Quoted 6 lines · Marek Vasut
Quoted 4 lines

, or the duplex TX/RX setup for channels
(channels are either RX or TX, not both), or the local echoing/loopback (which wouldn't make much sense for TX-only channels).

Aren't the RX-only/TX-only channels rather a special case ?

They're actually the only case AFAIK. You've got systems generating streams of ARINC429 words (e.g. the IRS, the FMC...) and systems that may consume the streams from multiple independent channels (e.g. the IFE). I try to think of each logical bus as a single transmitter broadcasting to multiple receivers.

Quoted 7 lines
Quoted 4 lines

I've re-checked the spec and it does say that there may be systems that act as source (TX) and sink (RX), e.g. DME, VOR or ILS. But in those cases, they will actually have separate TX and RX physical ports.

So, considering that hi3593 which as 2x RX and 1x TX port, what about registering one device per port and be done with it ?

Yes, as long as the RX device doesn't accept writing, and the TX device doesn't accept reading (except for echo I guess, if that ends up getting included), that would make sense. The kernel will need to specify somehow the port type clearly.

Signature · 2 lines
Aleksander
https://aleksander.es
#41 lore raw
In reply to Marek Vasut
Quoted 14 lines · Marek Vasut
Quoted 14 lines
Quoted 13 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

I was thinking about this and I mostly agree with you. Obviously, copying the code this way was dumb. On the other hand, ARINC and CAN are two different sort of busses, so I'd propose something slightly different here to avoid confusion and prevent the future extensions (or protocols) from adding unrelated cruft into the CAN stack.

I'd keep them separate not because ARINC may add unrelated cruft into the CAN stack, but because ARINC is much simpler than CAN already...

What about maintainability? Why take care of two almost identical subsystems? With making one stack "simpler" you increase, from my point of view, the costs of maintaining even more. If you fix problems in one stack you have to adopt the other, too.

Quoted 7 lines
Quoted 5 lines

If they can share common code, that's fine, that probably can be worked around if needed. My main issues are actually with all the behavior that CAN supports and doesn't make much sense in ARINC, like the complex ID filtering scheme for example (ARINC just requires 256 bits for a minimum filter)

So does CAN, I don't see a problem re-using the filtering infrastructure here.

Aren't CAN IDs more than 8-bit long?

Also, ARINC429 labels are logically identifying the data type of the value being sent, not a given "node" as CAN IDs are (If I'm not mistaken, correct me if wrong). A single system (e.g. IRS) will send multiple different labels (e.g. 310 for Latitude, 311 for Longitude...) to different consumers (e.g. IFE will read all those). The way a receiver identifies what system generated a given word (as the same label may have different meaning if sent by different systems) is usually by mapping in which RX port the word was received (or also through the special 377 label which may be used as equipment ID).

Signature · 2 lines
Aleksander
https://aleksander.es
#42 lore raw
Quoted 22 lines · Aleksander Morgado
Quoted 21 lines · Marek Vasut
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

I was thinking about this and I mostly agree with you. Obviously, copying the code this way was dumb. On the other hand, ARINC and CAN are two different sort of busses, so I'd propose something slightly different here to avoid confusion and prevent the future extensions (or protocols) from adding unrelated cruft into the CAN stack.

Quoted 7 lines
Quoted 2 lines

I'd keep them separate not because ARINC may add unrelated cruft into the CAN stack, but because ARINC is much simpler than CAN already...

What about maintainability? Why take care of two almost identical subsystems? With making one stack "simpler" you increase, from my point of view, the costs of maintaining even more. If you fix problems in one stack you have to adopt the other, too.

If they can share common code, that's fine, that probably can be worked around if needed. My main issues are actually with all the behavior that CAN supports and doesn't make much sense in ARINC, like the complex ID filtering scheme for example (ARINC just requires 256 bits for a minimum filter)

Quoted 4 lines
Quoted 2 lines

So does CAN, I don't see a problem re-using the filtering infrastructure here.

Aren't CAN IDs more than 8-bit long?

11bit for CAN, but that's a minor detail.

Quoted 5 lines

Also, ARINC429 labels are logically identifying the data type of the value being sent, not a given "node" as CAN IDs are (If I'm not mistaken, correct me if wrong). A single system (e.g. IRS) will send multiple different labels (e.g. 310 for Latitude, 311 for Longitude...) to different consumers (e.g. IFE will read all those).

In that case, filter those LABELs which you want to receive and decide on their datatype in your application based on the LABEL. This works just fine in my opinion.

On the other hand, you cansend those LABELs which you want to transmit as well, again the logic for determining which LABEL to send is in your application.

Quoted 5 lines

The way a receiver identifies what system generated a given word (as the same label may have different meaning if sent by different systems) is usually by mapping in which RX port the word was received (or also through the special 377 label which may be used as equipment ID).

Well that's fine, isn't it ?

Best regards,
Marek Vasut

#43 lore raw
In reply to Aleksander Morgado
Quoted 12 lines · Aleksander Morgado

Unrelated to all this, another key point in ARINC is the timing for each label when transmitting. The common case you get is different labels being sent continuously with a given rate for each. E.g. labels 310 and 311 every 80ms, label 312 every 120ms and so on. I'm not sure the HOLT chips have any specific way of configuring this, but I've seen some USB devices which actually have APIs to say e.g. "send label 310 every 80ms" and then you can just update the value being sent without needing to take care of the TX rate. I'd have loved to see that instead of the complex filtering :) I know this is way too much for the generic kernel driver, though, so just a heads up of how this usually works.

The CAN stack already has a solution for this.

The CAN_BCM socket is a programmable (content) filter for cyclic messages which are common in automotive setups to detect timeouts in cyclic messages (sender fails).

An the best thing: You can use the Linux internal high-res timers to send messages - just by creating a TX_SETUP configuration for the BCM.

Read this:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/networking/can.txt?h=linux-4.2.y#n634

Just one more reason to use PF_CAN :-)

#44 lore raw
Quoted 19 lines · Oliver Hartkopp
Quoted 12 lines

Unrelated to all this, another key point in ARINC is the timing for each label when transmitting. The common case you get is different labels being sent continuously with a given rate for each. E.g. labels 310 and 311 every 80ms, label 312 every 120ms and so on. I'm not sure the HOLT chips have any specific way of configuring this, but I've seen some USB devices which actually have APIs to say e.g. "send label 310 every 80ms" and then you can just update the value being sent without needing to take care of the TX rate. I'd have loved to see that instead of the complex filtering :) I know this is way too much for the generic kernel driver, though, so just a heads up of how this usually works.

The CAN stack already has a solution for this.

The CAN_BCM socket is a programmable (content) filter for cyclic messages which are common in automotive setups to detect timeouts in cyclic messages (sender fails).

Quoted 7 lines

An the best thing: You can use the Linux internal high-res timers to send messages - just by creating a TX_SETUP configuration for the BCM.

Read this:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/networking/can.txt?h=linux-4.2.y#n634

Just one more reason to use PF_CAN :-)

This setup is actually very interesting for ARINC transmitters, indeed.

Signature · 2 lines
Aleksander
https://aleksander.es
#45 lore raw
In reply to Marek Vasut
Quoted 87 lines · Marek Vasut
Quoted 23 lines · Oliver Hartkopp
Quoted 22 lines · Marc Kleine-Budde
Quoted 20 lines · Marek Vasut

The ARINC-429 is a technical standard, which describes, among others, a data bus used by airplanes. The standard contains much more, since it is based off the ISO/OSI model, but this patch implements just the data bus protocol.

This stack is derived from the SocketCAN implementation, already present in the kernel and thus behaves in a very similar fashion. Thus far, we support sending RAW ARINC-429 datagrams, configuration of the RX and TX clock speed and filtering.

The ARINC-429 datagram is four-byte long. The first byte is always the LABEL, the function of remaining three bytes can vary, so we handle it as an opaque PAYLOAD. The userspace tools can send these datagrams via a standard socket.

A LABEL-based filtering can be configured on each socket separately in a way comparable to CAN -- user uses setsockopt() to push a list of label,mask tuples into the kernel and the kernel will deliver a datagram to the socket if (<received_label> & mask) == (label & mask), otherwise the datagram is not delivered.

Quoted 5 lines
Quoted 3 lines

What's difference compared to CAN besides a different MTU? The CAN stack is already capable to handle CAN and CAN-FD frames. Would it make sense to integrate the ARINC-429 into the existing CAN stack?

That was my first impression too.

Hi!

Quoted 2 lines

What about defining some overlay data structure to map ARINC-429 frames into CAN frames?

I agree about the code reuse, it was stupid to do such a blatant copy of the code all right. I don't think it's such a great idea to outright place ARINC support into the CAN stack though. They're two different busses after all. Please see below.

Quoted 8 lines

E.g. we could write the ARINC 32 bit data completely into data[0..3] and additionally copy the 8 bit label information (or should it better be 10 bit including the Source/Destination Identifiers?) additionally into the can_id.

From what I can see the filtering by label is similar to filtering by

can_id. And you would be able to use the can-gw functionality too.

This is correct.

Quoted 2 lines

The only real difference is the bitrate configuration of the ARINC interface.

There might be additional ARINC-specific configuration bits involved, but thus far, that's correct.

Quoted 4 lines

I wonder if a similar approach would fit here as we discussed with the University of Prague for a LIN implementation using the PF_CAN

infrastructure:

OT: Hey, there is no "University of Prague", there are two universities in Prague to boot -- Charles University and Czech Technical University -- you mean the later ;-)

Quoted 4 lines

http://rtime.felk.cvut.cz/can/lin-bus/

It could probably boil down to a 'CAN interface' that is named arinc0 which implements the serial driver like in slcan.c or sllin.c ...

I was thinking about this and I mostly agree with you. Obviously, copying the code this way was dumb. On the other hand, ARINC and CAN are two different sort of busses, so I'd propose something slightly different here to avoid confusion and prevent the future extensions (or protocols) from adding unrelated cruft into the CAN stack.

I would propose we (read: me) create some sort of "common" core, which would contain the following:
- drivers/net/: big part of the device interface here is common big part of the virtual interface here is common -> CAN or ARINC can just add their own specific callbacks
and be done with it

- net/: there's a lot of common parts as well, like the filtering can be unified such that it can be used by both. A big part of the socket handling is also similar.

Quoted 7 lines

This would also let the slcan or sllin or whatever stuff they made at CVUT just plug into this "common" core part.

Now I wonder if we should introduce AF_ARINC or stick to AF_CAN for both. I'd be much happier to keep those two separate, again, to avoid confusion.

What do you think please ?

So, what do you think about this approach -- pulling out common core code from CAN (so it can be re-used for ARINC) and having both of those (CAN and ARINC) implement just a thin layer of adaptation code for this core ? Would this make sense to you?