1f1afe329ab43b2cc29bf459b34dd0b88c255192
[openwrt/staging/wigyori.git] / target / linux / layerscape / patches-5.4 / 701-net-0043-sdk_dpaa-ceetm-stop-transmitting-frames-when-the-CQ-.patch
1 From 3aa939c73c176690a9ebe646612cd097f281efe5 Mon Sep 17 00:00:00 2001
2 From: Camelia Groza <camelia.groza@nxp.com>
3 Date: Fri, 24 Nov 2017 10:48:31 +0200
4 Subject: [PATCH] sdk_dpaa: ceetm: stop transmitting frames when the CQ is
5 congested
6
7 When the egress CQ is congested, drop the frames instead of enqueueing
8 them. This is more efficient than enqueueing and receiving them back on
9 the ERN queue.
10
11 We also can't stop the netdev queues because that would affect all the CQs
12 and would hinder prioritization.
13
14 Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
15 ---
16 .../ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c | 22 ++++++++++++++++------
17 .../ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h | 1 +
18 2 files changed, 17 insertions(+), 6 deletions(-)
19
20 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
21 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
22 @@ -125,16 +125,16 @@ static void ceetm_cscn(struct qm_ceetm_c
23 break;
24 }
25
26 + ceetm_fq->congested = congested;
27 +
28 if (congested) {
29 dpa_priv->cgr_data.congestion_start_jiffies = jiffies;
30 - netif_tx_stop_all_queues(dpa_priv->net_dev);
31 dpa_priv->cgr_data.cgr_congested_count++;
32 if (cstats)
33 cstats->congested_count++;
34 } else {
35 dpa_priv->cgr_data.congested_jiffies +=
36 (jiffies - dpa_priv->cgr_data.congestion_start_jiffies);
37 - netif_tx_wake_all_queues(dpa_priv->net_dev);
38 }
39 }
40
41 @@ -148,6 +148,7 @@ static int ceetm_alloc_fq(struct ceetm_f
42
43 (*fq)->net_dev = dev;
44 (*fq)->ceetm_cls = cls;
45 + (*fq)->congested = 0;
46 return 0;
47 }
48
49 @@ -1913,7 +1914,8 @@ int __hot ceetm_tx(struct sk_buff *skb,
50 struct Qdisc *sch = net_dev->qdisc;
51 struct ceetm_class *cl;
52 struct dpa_priv_s *priv_dpa;
53 - struct qman_fq *egress_fq, *conf_fq;
54 + struct ceetm_fq *ceetm_fq;
55 + struct qman_fq *conf_fq;
56 struct ceetm_qdisc *priv = qdisc_priv(sch);
57 struct ceetm_qdisc_stats *qstats = this_cpu_ptr(priv->root.qstats);
58 struct ceetm_class_stats *cstats;
59 @@ -1945,11 +1947,11 @@ int __hot ceetm_tx(struct sk_buff *skb,
60 */
61 switch (cl->type) {
62 case CEETM_PRIO:
63 - egress_fq = &cl->prio.fq->fq;
64 + ceetm_fq = cl->prio.fq;
65 cstats = this_cpu_ptr(cl->prio.cstats);
66 break;
67 case CEETM_WBFS:
68 - egress_fq = &cl->wbfs.fq->fq;
69 + ceetm_fq = cl->wbfs.fq;
70 cstats = this_cpu_ptr(cl->wbfs.cstats);
71 break;
72 default:
73 @@ -1957,8 +1959,16 @@ int __hot ceetm_tx(struct sk_buff *skb,
74 goto drop;
75 }
76
77 + /* If the FQ is congested, avoid enqueuing the frame and dropping it
78 + * when it returns on the ERN path. Drop it here directly instead.
79 + */
80 + if (unlikely(ceetm_fq->congested)) {
81 + qstats->drops++;
82 + goto drop;
83 + }
84 +
85 bstats_update(&cstats->bstats, skb);
86 - return dpa_tx_extended(skb, net_dev, egress_fq, conf_fq);
87 + return dpa_tx_extended(skb, net_dev, &ceetm_fq->fq, conf_fq);
88
89 drop:
90 dev_kfree_skb_any(skb);
91 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h
92 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h
93 @@ -105,6 +105,7 @@ struct ceetm_fq {
94 struct qman_fq fq;
95 struct net_device *net_dev;
96 struct ceetm_class *ceetm_cls;
97 + int congested; /* Congestion status */
98 };
99
100 struct root_q {