aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0292-staging-fsl_ppfe-eth-Avoid-packet-drop-at-TMU-queues.patch
blob: eeea3740dd87466105d8719ea31b9b48d27b0ae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From 8b99b4595d2b5f4d0b2252b16de83572e03b337a Mon Sep 17 00:00:00 2001
From: Kavi Akhila-B46177 <akhila.kavi@nxp.com>
Date: Thu, 2 Nov 2017 12:05:35 +0530
Subject: [PATCH] staging: fsl_ppfe/eth: Avoid packet drop at TMU queues

Added flow control between TMU queues and PFE Linux driver,
based on TMU credits availability.
Added tx_qos module parameter to control this behavior.
Use queue-0 as default queue to transmit packets.

Signed-off-by: Calvin Johnson <calvin.johnson@nxp.com>
Signed-off-by: Akhila Kavi <akhila.kavi@nxp.com>
Signed-off-by: Anjaneyulu Jagarlmudi <anji.jagarlmudi@nxp.com>
---
 drivers/staging/fsl_ppfe/pfe_eth.c     | 17 +++++++++++++----
 drivers/staging/fsl_ppfe/pfe_hif_lib.c |  7 +++++--
 2 files changed, 18 insertions(+), 6 deletions(-)

--- a/drivers/staging/fsl_ppfe/pfe_eth.c
+++ b/drivers/staging/fsl_ppfe/pfe_eth.c
@@ -293,10 +293,10 @@ static int pfe_eth_sysfs_init(struct net
 	/* Initialize the default values */
 
 	/*
-	 * By default, packets without conntrack will use this default high
+	 * By default, packets without conntrack will use this default low
 	 * priority queue
 	 */
-	priv->default_priority = 15;
+	priv->default_priority = 0;
 
 	/* Create our sysfs files */
 	err = device_create_file(&ndev->dev, &dev_attr_default_priority);
@@ -1566,10 +1566,17 @@ static int pfe_eth_might_stop_tx(struct
 				 unsigned int n_segs)
 {
 	ktime_t kt;
+	int tried = 0;
 
+try_again:
 	if (unlikely((__hif_tx_avail(&pfe->hif) < n_desc) ||
-		     (hif_lib_tx_avail(&priv->client, queuenum) < n_desc) ||
+	(hif_lib_tx_avail(&priv->client, queuenum) < n_desc) ||
 	(hif_lib_tx_credit_avail(pfe, priv->id, queuenum) < n_segs))) {
+		if (!tried) {
+			__hif_lib_update_credit(&priv->client, queuenum);
+			tried = 1;
+			goto try_again;
+		}
 #ifdef PFE_ETH_TX_STATS
 		if (__hif_tx_avail(&pfe->hif) < n_desc) {
 			priv->stop_queue_hif[queuenum]++;
@@ -1692,8 +1699,10 @@ static void pfe_eth_flush_tx(struct pfe_
 
 	netif_info(priv, tx_done, priv->ndev, "%s\n", __func__);
 
-	for (ii = 0; ii < emac_txq_cnt; ii++)
+	for (ii = 0; ii < emac_txq_cnt; ii++) {
 		pfe_eth_flush_txQ(priv, ii, 0, 0);
+		__hif_lib_update_credit(&priv->client, ii);
+	}
 }
 
 void pfe_tx_get_req_desc(struct sk_buff *skb, unsigned int *n_desc, unsigned int
--- a/drivers/staging/fsl_ppfe/pfe_hif_lib.c
+++ b/drivers/staging/fsl_ppfe/pfe_hif_lib.c
@@ -34,7 +34,10 @@
 
 unsigned int lro_mode;
 unsigned int page_mode;
-unsigned int tx_qos;
+unsigned int tx_qos = 1;
+module_param(tx_qos, uint, 0444);
+MODULE_PARM_DESC(tx_qos, "0: disable ,\n"
+			 "1: enable (default), guarantee no packet drop at TMU level\n");
 unsigned int pfe_pkt_size;
 unsigned int pfe_pkt_headroom;
 unsigned int emac_txq_cnt;
@@ -576,7 +579,7 @@ void __hif_lib_update_credit(struct hif_
 
 	if (tx_qos) {
 		tmu_tx_packets = be32_to_cpu(pe_dmem_read(TMU0_ID +
-			client->id, TMU_DM_TX_TRANS, 4));
+			client->id, (TMU_DM_TX_TRANS + (queue * 4)), 4));
 
 		/* tx_packets counter overflowed */
 		if (tmu_tx_packets >