API to support hardware priorities (was: Re: API zur hardwareunterstützten Priorisierung von CAN-Paketen)
A message that is not in the archive (sent off-list or not yet received): 20151109123618.41ad1bae@mitra
Marc Kleine-Budde
maintainerLet's move this discussion to the mailing list. I'll translate your questions.
Quoted 3 lines · Benedikt Spranger
C-CAN und D-CAN basierte Hardware (wie auch andere) unterstützt ja das priorisierende Versenden von CAN-Paketen. Gibt es Bestrebungen, dieses Feature in der API abzubilden?
Several CAN IP cores support prioritisation of CAN frames. Is it planned to support this?
Quoted 5 lines
Im konkreten Fall werden neben Bulk-Daten azyklisch auch zeitkritische CAN-Pakete versendet. Hierbei ist eine FIFO-Abarbeitung störend. Das Mailbox-basierte Design von C-CAN/D-CAN unterstützt ja neben der Verwendung der Mailboxen als FIFO auch die dedizierte Konfiguration auf eine CAN-Id/Maske.
Bene want to send bulk data and time critical cyclic data. Using a hardware FIFO introduces unwanted latencies. He further mentions that it's possible to configure the mailboxes to serve a CAN-ID/mask.
Hope I've got the gist of your mail, correct me if needed. :)
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 |
Marc Kleine-Budde
maintainerRe: API to support hardware priorities
Quoted 10 lines · Marc Kleine-Budde
Let's move this discussion to the mailing list. I'll translate your questions.
Quoted 3 lines · Benedikt Spranger
C-CAN und D-CAN basierte Hardware (wie auch andere) unterstützt ja das priorisierende Versenden von CAN-Paketen. Gibt es Bestrebungen, dieses Feature in der API abzubilden?
Several CAN IP cores support prioritisation of CAN frames. Is it planned to support this?
There are two buffers before a CAN frame gets send to the wire:
First there is the queueing in the network layer. You can replace the FIFO of the interface by a multi prio queue and filter your CAN frames by CAN-ID.
The second buffer might be the in the hardware. For now each driver ensures that the buffer in configured as a FIFO. Some CAN IP cores support sending CAN frames based on the CAN-ID (lowest ID first), some have a priority value, some cores even combine these two.
Several thoughts on this:
IIRC the kernel networking driver API supports several TX queues per networking device. We might be exploited this to implement a bulk large FIFO queue and a high prio no just one buffer TX queue per driver.
We can introduce a per device knob to switch a CAN driver from true TX FIFO mode to CAN-ID based priority TX mode. The driver's TX and TX-complete routines have to be adopted as they now assume that the CAN frames are send in true FIFO order. The feature can be toggled via netlink/canconfig.
Quoted 9 lines
Quoted 5 lines
Im konkreten Fall werden neben Bulk-Daten azyklisch auch zeitkritische CAN-Pakete versendet. Hierbei ist eine FIFO-Abarbeitung störend. Das Mailbox-basierte Design von C-CAN/D-CAN unterstützt ja neben der Verwendung der Mailboxen als FIFO auch die dedizierte Konfiguration auf eine CAN-Id/Maske.
Bene want to send bulk data and time critical cyclic data. Using a hardware FIFO introduces unwanted latencies. He further mentions that it's possible to configure the mailboxes to serve a CAN-ID/mask.
Are we talking about RX or TX here?
Do you mean the mailbox feature, where you queue a frame into hardware, but sending is delayed until a certain CAN-ID is RX'ed?
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 |
Re: API to support hardware priorities
Hopefully the webmailer doesn't kill the formatting ... but it seems to be urgent :-)
We have an ematch implementation for CAN:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/sched/em_canid.c
See idea here:
http://rtime.felk.cvut.cz/can/socketcan-qdisc-final.pdf
The idea is still to have a very short TX FIFO in the driver and fix the 'multi-user' issues in the TX part of the queueing-disciplines.
Regards,
Oliver
Quoted 61 lines
Marc Kleine-Budde <[email protected]> hat am 9. November 2015 um 14:51 geschrieben:
Quoted 10 lines · Marc Kleine-Budde
Let's move this discussion to the mailing list. I'll translate your questions.
Quoted 3 lines · Benedikt Spranger
C-CAN und D-CAN basierte Hardware (wie auch andere) unterstützt ja das priorisierende Versenden von CAN-Paketen. Gibt es Bestrebungen, dieses Feature in der API abzubilden?
Several CAN IP cores support prioritisation of CAN frames. Is it planned to support this?
There are two buffers before a CAN frame gets send to the wire:
First there is the queueing in the network layer. You can replace the FIFO of the interface by a multi prio queue and filter your CAN frames by CAN-ID.The second buffer might be the in the hardware. For now each driver ensures that the buffer in configured as a FIFO. Some CAN IP cores support sending CAN frames based on the CAN-ID (lowest ID first), some have a priority value, some cores even combine these two.
Several thoughts on this:
IIRC the kernel networking driver API supports several TX queues per networking device. We might be exploited this to implement a bulk large FIFO queue and a high prio no just one buffer TX queue per driver.
We can introduce a per device knob to switch a CAN driver from true TX FIFO mode to CAN-ID based priority TX mode. The driver's TX and TX-complete routines have to be adopted as they now assume that the CAN frames are send in true FIFO order. The feature can be toggled via netlink/canconfig.
Quoted 9 lines
Quoted 5 lines
Im konkreten Fall werden neben Bulk-Daten azyklisch auch zeitkritische CAN-Pakete versendet. Hierbei ist eine FIFO-Abarbeitung störend. Das Mailbox-basierte Design von C-CAN/D-CAN unterstützt ja neben der Verwendung der Mailboxen als FIFO auch die dedizierte Konfiguration auf eine CAN-Id/Maske.
Bene want to send bulk data and time critical cyclic data. Using a hardware FIFO introduces unwanted latencies. He further mentions that it's possible to configure the mailboxes to serve a CAN-ID/mask.
Are we talking about RX or TX here?
Do you mean the mailbox feature, where you queue a frame into hardware, but sending is delayed until a certain CAN-ID is RX'ed?
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 |
Re: API to support hardware priorities
In reply to Marc Kleine-BuddeQuoted 1 line · On Mon, 9 Nov 2015 14:51:32 +0100 Marc Kleine-Budde <[email protected]> wrote:
Are we talking about RX or TX here?
TX.
Quoted 2 lines
Do you mean the mailbox feature, where you queue a frame into hardware, but sending is delayed until a certain CAN-ID is RX'ed?
No.
The C-CAN/D-CAN and some other Controller can be configured to have mailboxes for a certain Id. For example you can configure MBX 1 for Id 23, MBX 2 for Id 42 and 3-7 act as FIFO. So every packet matching Id 23 should queued up to MBX 1, every package matching Id 42 to MBX 2 and all other Packages to the FIFO.
Having a multiqueue TX part may help but may have some drawbacks. If the FIFO (or an other queue) is full the driver calls netif_stop_queue(). Sending bulk data can block out a "high priority" Package. On the other hand a application writing bulk data in blocking mode should not receive a EAGAIN and not be punished by a "mixed up" queue i.e. violating the package send order.
Regards
Bene
Signature · 8 lines
Linutronix GmbH Phone: +49 7556 4521 890; Fax.: +49 7556 91 98 86 Firmensitz: D-88690 Uhldingen, Auf dem Berg 3 Registergericht: Freiburg i. Br., HRB 700 806; Geschäftsführer: Heinz Egger, Thomas Gleixner
Marc Kleine-Budde
maintainerRe: API to support hardware priorities
Quoted 8 lines · Benedikt Spranger
Quoted 2 lines
Do you mean the mailbox feature, where you queue a frame into hardware, but sending is delayed until a certain CAN-ID is RX'ed?
No.
The C-CAN/D-CAN and some other Controller can be configured to have mailboxes for a certain Id. For example you can configure MBX 1 for Id 23, MBX 2 for Id 42 and 3-7 act as FIFO. So every packet matching Id 23 should queued up to MBX 1, every package matching Id 42 to MBX 2 and all other Packages to the FIFO.
OK, I was not aware of that feature. I'll have a look to the datasheets. What's the benefit of associating a mailbox to a specific ID in the hardware?
Quoted 2 lines
Having a multiqueue TX part may help but may have some drawbacks. If the FIFO (or an other queue) is full the driver calls
netif_stop_queue().
In this scenario there will be two netif_queues per CAN driver....
Quoted 4 lines
Sending bulk data can block out a "high priority" Package. On the other hand a application writing bulk data in blocking mode should not receive a EAGAIN and not be punished by a "mixed up" queue i.e. violating the package send order.
...one serving the bulk hardware FIFO and one serving the high prio HW queue.
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 |
Re: API to support hardware priorities
Am Mon, 9 Nov 2015 16:38:09 +0100
schrieb Marc Kleine-Budde <[email protected]>:
Quoted 3 lines
OK, I was not aware of that feature. I'll have a look to the datasheets. What's the benefit of associating a mailbox to a specific ID in the hardware?
A "stop all engines. NOW!"-message would not blocked by 1001 bulk messages telling about air pressure, temperature and sunshine. Look at it from a "classic" microcontroller POV.
Quoted 1 line
...one serving the bulk hardware FIFO and one serving the high prio HW
"tree/net/sched/em_canid.c" and multiple queues look promising.
Will have a deeper look at it.
Regards
Bene