[RCAR] disable a default config in kernel
[AGL/meta-agl.git] / meta-agl-core / recipes-kernel / linux / linux / net-sch_generic-Use-pfifo_fast-as-fallback-scheduler.patch
1 From 546b85bb0aadb5a928b49b53dc02911996169c0b Mon Sep 17 00:00:00 2001
2 From: Vincent Prince <vincent.prince.fr@gmail.com>
3 Date: Wed, 23 Oct 2019 15:44:20 +0200
4 Subject: [PATCH] net: sch_generic: Use pfifo_fast as fallback scheduler for
5  CAN hardware
6
7 There is networking hardware that isn't based on Ethernet for layers 1 and 2.
8
9 For example CAN.
10
11 CAN is a multi-master serial bus standard for connecting Electronic Control
12 Units [ECUs] also known as nodes. A frame on the CAN bus carries up to 8 bytes
13 of payload. Frame corruption is detected by a CRC. However frame loss due to
14 corruption is possible, but a quite unusual phenomenon.
15
16 While fq_codel works great for TCP/IP, it doesn't for CAN. There are a lot of
17 legacy protocols on top of CAN, which are not build with flow control or high
18 CAN frame drop rates in mind.
19
20 When using fq_codel, as soon as the queue reaches a certain delay based length,
21 skbs from the head of the queue are silently dropped. Silently meaning that the
22 user space using a send() or similar syscall doesn't get an error. However
23 TCP's flow control algorithm will detect dropped packages and adjust the
24 bandwidth accordingly.
25
26 When using fq_codel and sending raw frames over CAN, which is the common use
27 case, the user space thinks the package has been sent without problems, because
28 send() returned without an error. pfifo_fast will drop skbs, if the queue
29 length exceeds the maximum. But with this scheduler the skbs at the tail are
30 dropped, an error (-ENOBUFS) is propagated to user space. So that the user
31 space can slow down the package generation.
32
33 On distributions, where fq_codel is made default via CONFIG_DEFAULT_NET_SCH
34 during compile time, or set default during runtime with sysctl
35 net.core.default_qdisc (see [1]), we get a bad user experience. In my test case
36 with pfifo_fast, I can transfer thousands of million CAN frames without a frame
37 drop. On the other hand with fq_codel there is more then one lost CAN frame per
38 thousand frames.
39
40 As pointed out fq_codel is not suited for CAN hardware, so this patch changes
41 attach_one_default_qdisc() to use pfifo_fast for "ARPHRD_CAN" network devices.
42
43 During transition of a netdev from down to up state the default queuing
44 discipline is attached by attach_default_qdiscs() with the help of
45 attach_one_default_qdisc(). This patch modifies attach_one_default_qdisc() to
46 attach the pfifo_fast (pfifo_fast_ops) if the network device type is
47 "ARPHRD_CAN".
48
49 [1] https://github.com/systemd/systemd/issues/9194
50
51 Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
52 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
53 Signed-off-by: Vincent Prince <vincent.prince.fr@gmail.com>
54 Acked-by: Dave Taht <dave.taht@gmail.com>
55 Signed-off-by: David S. Miller <davem@davemloft.net>
56 ---
57  net/sched/sch_generic.c | 2 ++
58  1 file changed, 2 insertions(+)
59
60 diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
61 index ed5b0e9fd395..4c5dfcb01e00 100644
62 --- a/net/sched/sch_generic.c
63 +++ b/net/sched/sch_generic.c
64 @@ -1038,6 +1038,8 @@ static void attach_one_default_qdisc(struct net_device *dev,
65  
66         if (dev->priv_flags & IFF_NO_QUEUE)
67                 ops = &noqueue_qdisc_ops;
68 +       else if(dev->type == ARPHRD_CAN)
69 +               ops = &pfifo_fast_ops;
70  
71         qdisc = qdisc_create_dflt(dev_queue, ops, TC_H_ROOT, NULL);
72         if (!qdisc) {
73 -- 
74 2.25.0
75