ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 701-net-0292-staging-fsl_ppfe-eth-Avoid-packet-drop-at-TMU-queues.patch
1 From 8b99b4595d2b5f4d0b2252b16de83572e03b337a Mon Sep 17 00:00:00 2001
2 From: Kavi Akhila-B46177 <akhila.kavi@nxp.com>
3 Date: Thu, 2 Nov 2017 12:05:35 +0530
4 Subject: [PATCH] staging: fsl_ppfe/eth: Avoid packet drop at TMU queues
5
6 Added flow control between TMU queues and PFE Linux driver,
7 based on TMU credits availability.
8 Added tx_qos module parameter to control this behavior.
9 Use queue-0 as default queue to transmit packets.
10
11 Signed-off-by: Calvin Johnson <calvin.johnson@nxp.com>
12 Signed-off-by: Akhila Kavi <akhila.kavi@nxp.com>
13 Signed-off-by: Anjaneyulu Jagarlmudi <anji.jagarlmudi@nxp.com>
14 ---
15  drivers/staging/fsl_ppfe/pfe_eth.c     | 17 +++++++++++++----
16  drivers/staging/fsl_ppfe/pfe_hif_lib.c |  7 +++++--
17  2 files changed, 18 insertions(+), 6 deletions(-)
18
19 --- a/drivers/staging/fsl_ppfe/pfe_eth.c
20 +++ b/drivers/staging/fsl_ppfe/pfe_eth.c
21 @@ -293,10 +293,10 @@ static int pfe_eth_sysfs_init(struct net
22         /* Initialize the default values */
23  
24         /*
25 -        * By default, packets without conntrack will use this default high
26 +        * By default, packets without conntrack will use this default low
27          * priority queue
28          */
29 -       priv->default_priority = 15;
30 +       priv->default_priority = 0;
31  
32         /* Create our sysfs files */
33         err = device_create_file(&ndev->dev, &dev_attr_default_priority);
34 @@ -1566,10 +1566,17 @@ static int pfe_eth_might_stop_tx(struct
35                                  unsigned int n_segs)
36  {
37         ktime_t kt;
38 +       int tried = 0;
39  
40 +try_again:
41         if (unlikely((__hif_tx_avail(&pfe->hif) < n_desc) ||
42 -                    (hif_lib_tx_avail(&priv->client, queuenum) < n_desc) ||
43 +       (hif_lib_tx_avail(&priv->client, queuenum) < n_desc) ||
44         (hif_lib_tx_credit_avail(pfe, priv->id, queuenum) < n_segs))) {
45 +               if (!tried) {
46 +                       __hif_lib_update_credit(&priv->client, queuenum);
47 +                       tried = 1;
48 +                       goto try_again;
49 +               }
50  #ifdef PFE_ETH_TX_STATS
51                 if (__hif_tx_avail(&pfe->hif) < n_desc) {
52                         priv->stop_queue_hif[queuenum]++;
53 @@ -1692,8 +1699,10 @@ static void pfe_eth_flush_tx(struct pfe_
54  
55         netif_info(priv, tx_done, priv->ndev, "%s\n", __func__);
56  
57 -       for (ii = 0; ii < emac_txq_cnt; ii++)
58 +       for (ii = 0; ii < emac_txq_cnt; ii++) {
59                 pfe_eth_flush_txQ(priv, ii, 0, 0);
60 +               __hif_lib_update_credit(&priv->client, ii);
61 +       }
62  }
63  
64  void pfe_tx_get_req_desc(struct sk_buff *skb, unsigned int *n_desc, unsigned int
65 --- a/drivers/staging/fsl_ppfe/pfe_hif_lib.c
66 +++ b/drivers/staging/fsl_ppfe/pfe_hif_lib.c
67 @@ -34,7 +34,10 @@
68  
69  unsigned int lro_mode;
70  unsigned int page_mode;
71 -unsigned int tx_qos;
72 +unsigned int tx_qos = 1;
73 +module_param(tx_qos, uint, 0444);
74 +MODULE_PARM_DESC(tx_qos, "0: disable ,\n"
75 +                        "1: enable (default), guarantee no packet drop at TMU level\n");
76  unsigned int pfe_pkt_size;
77  unsigned int pfe_pkt_headroom;
78  unsigned int emac_txq_cnt;
79 @@ -576,7 +579,7 @@ void __hif_lib_update_credit(struct hif_
80  
81         if (tx_qos) {
82                 tmu_tx_packets = be32_to_cpu(pe_dmem_read(TMU0_ID +
83 -                       client->id, TMU_DM_TX_TRANS, 4));
84 +                       client->id, (TMU_DM_TX_TRANS + (queue * 4)), 4));
85  
86                 /* tx_packets counter overflowed */
87                 if (tmu_tx_packets >