From 35efc0f34b56ca9d5fb5d080d5de0833ded7e3b8 Mon Sep 17 00:00:00 2001
From: Anji J <anji.jagarlmudi@freescale.com>
Date: Tue, 21 Jun 2016 13:25:12 +0530
Subject: [PATCH 66/93] armv8:pfe Enable UDP checksum for proper tftp
 operation

1. Add CONFIG_UDP_CHECKSUM flag to perform UDP checksum in S/W
   instead of hardware
2. Rx descriptor model changed back to original
   removed strobe mode
3. Send more than one dummy packets to bring HIF BD to idle state

Signed-off-by: Anji J <anji.jagarlmudi@freescale.com>
---
 common/cmd_pfe_commands.c        |   12 +++++++-----
 drivers/net/pfe_eth/pfe_driver.c |   19 +++----------------
 include/configs/ls1012a_common.h |    1 +
 3 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/common/cmd_pfe_commands.c b/common/cmd_pfe_commands.c
index 92917e0..3575ad4 100644
--- a/common/cmd_pfe_commands.c
+++ b/common/cmd_pfe_commands.c
@@ -929,7 +929,7 @@ static void send_dummy_pkt_to_hif(void)
 
 static void pfe_command_stop(int argc, char * const argv[])
 {
-	int id;
+	int id, hif_stop_loop = 10;
 	u32 rx_status;
 	printf("Stopping PFE... \n");
 
@@ -937,10 +937,12 @@ static void pfe_command_stop(int argc, char * const argv[])
 	hif_rx_desc_disable();
 
 	/*If HIF Rx BDP is busy send a dummy packet */
-	rx_status = readl(HIF_RX_STATUS);
-	if(rx_status & BDP_CSR_RX_DMA_ACTV)
-		send_dummy_pkt_to_hif();
-	udelay(10);
+	do {
+		rx_status = readl(HIF_RX_STATUS);
+		if (rx_status & BDP_CSR_RX_DMA_ACTV)
+			send_dummy_pkt_to_hif();
+		udelay(10);
+	} while (hif_stop_loop--);
 
 	if(readl(HIF_RX_STATUS) & BDP_CSR_RX_DMA_ACTV)
 		printf("Unable to stop HIF\n");
diff --git a/drivers/net/pfe_eth/pfe_driver.c b/drivers/net/pfe_eth/pfe_driver.c
index e252fcf..6774fb4 100644
--- a/drivers/net/pfe_eth/pfe_driver.c
+++ b/drivers/net/pfe_eth/pfe_driver.c
@@ -37,13 +37,8 @@ int pfe_recv(unsigned int *pkt_ptr, int *phy_port)
 
 	bd = rx_desc->rxBase + rx_desc->rxToRead;
 
-	if (bd->ctrl & BD_CTRL_DESC_EN) {
-		if(!(readl(HIF_RX_STATUS) & BDP_CSR_RX_DMA_ACTV)){
-			/*If BDP is not active give write strobe */
-			writel((readl(HIF_RX_CTRL) | HIF_CTRL_BDP_CH_START_WSTB), HIF_RX_CTRL);
-		}
+	if (bd->ctrl & BD_CTRL_DESC_EN)
 		return len; //No pending Rx packet
-	}
 
 	/* this len include hif_header(8bytes) */
 	len = bd->ctrl & 0xFFFF;
@@ -72,15 +67,10 @@ int pfe_recv(unsigned int *pkt_ptr, int *phy_port)
 	*phy_port = hif_header->port_no;
 	len -= sizeof(struct hif_header_s);
 
-#if defined(PFE_LS1012A_RESET_WA)
-	/* reset bd control field */
-	ctrl = (MAX_FRAME_SIZE | BD_CTRL_LAST_BD | BD_CTRL_LIFM | BD_CTRL_DESC_EN | BD_CTRL_DIR);
-#else
 	/* reset bd control field */
 	ctrl = (MAX_FRAME_SIZE | BD_CTRL_LIFM | BD_CTRL_DESC_EN | BD_CTRL_DIR);
-	/* If we use BD_CTRL_LAST_BD, rxToRead never changes */
 	rx_desc->rxToRead = (rx_desc->rxToRead + 1) & (rx_desc->rxRingSize - 1);
-#endif
+
 	bd->ctrl = ctrl;
 	bd->status = 0;
 
@@ -363,11 +353,8 @@ static int hif_rx_desc_init(struct pfe *pfe)
 
 	memset(bd_va, 0, sizeof(struct bufDesc) * rx_desc->rxRingSize);
 
-#if defined(PFE_LS1012A_RESET_WA)
-	ctrl = (MAX_FRAME_SIZE | BD_CTRL_LAST_BD | BD_CTRL_DESC_EN | BD_CTRL_DIR | BD_CTRL_LIFM);
-#else
 	ctrl = (MAX_FRAME_SIZE | BD_CTRL_DESC_EN | BD_CTRL_DIR | BD_CTRL_LIFM);
-#endif
+
 	for (i=0; i < rx_desc->rxRingSize; i++) {
 		bd_va->next = (unsigned long)(bd_pa + 1);
 		bd_va->ctrl = ctrl;
diff --git a/include/configs/ls1012a_common.h b/include/configs/ls1012a_common.h
index 4c7c697..47b8ec3 100644
--- a/include/configs/ls1012a_common.h
+++ b/include/configs/ls1012a_common.h
@@ -116,6 +116,7 @@
 #ifdef CONFIG_FSL_PPFE
 #define CONFIG_CMD_PFE_COMMANDS
 #define CONFIG_UTIL_PE_DISABLED
+#define CONFIG_UDP_CHECKSUM
 
 #endif
 
-- 
1.7.9.5

