1 From 2b3d05ed1cb560b3a0b0721435c2fd73a19bd9bc Mon Sep 17 00:00:00 2001
2 From: Iordache Florinel-R70177 <florinel.iordache@nxp.com>
3 Date: Mon, 29 May 2017 09:25:24 +0300
4 Subject: [PATCH] sdk_fman: DPAA-dTSEC ports fail to work when link changes
6 Signed-off-by: Iordache Florinel-R70177 <florinel.iordache@nxp.com>
8 .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c | 57 ++++++++++++++++++----
9 1 file changed, 48 insertions(+), 9 deletions(-)
11 --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
12 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
13 @@ -386,6 +386,7 @@ static void FreeInitResources(t_Dtsec *p
14 static t_Error GracefulStop(t_Dtsec *p_Dtsec, e_CommMode mode)
16 struct dtsec_regs *p_MemMap;
17 + int pollTimeout = 0;
21 @@ -408,16 +409,32 @@ static t_Error GracefulStop(t_Dtsec *p_D
24 if (mode & e_COMM_MODE_TX)
25 -#if defined(FM_GTS_ERRATA_DTSEC_A004) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012)
26 - if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
27 - DBG(INFO, ("GTS not supported due to DTSEC_A004 errata."));
28 -#else /* not defined(FM_GTS_ERRATA_DTSEC_A004) ||... */
29 -#ifdef FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014
30 - DBG(INFO, ("GTS not supported due to DTSEC_A0014 errata."));
31 -#else /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */
33 +#if defined(FM_GTS_ERRATA_DTSEC_A004)
34 + if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
35 + DBG(INFO, ("GTS not supported due to DTSEC_A004 errata."));
36 +#else /* not defined(FM_GTS_ERRATA_DTSEC_A004) */
38 fman_dtsec_stop_tx(p_MemMap);
39 -#endif /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */
40 -#endif /* defined(FM_GTS_ERRATA_DTSEC_A004) ||... */
42 +#if defined(FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012)
44 +#endif /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 || FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012 */
45 +#endif /* defined(FM_GTS_ERRATA_DTSEC_A004) */
48 + /* Poll GRSC/GTSC bits in IEVENT register until both are set */
49 +#if defined(FM_GRS_ERRATA_DTSEC_A002) || defined(FM_GTS_ERRATA_DTSEC_A004) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012) || defined(FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014) || defined(FM_GTS_AFTER_DROPPED_FRAME_ERRATA_DTSEC_A004839)
52 + while (fman_dtsec_get_event(p_MemMap, DTSEC_IMASK_GRSCEN | DTSEC_IMASK_GTSCEN) != (DTSEC_IMASK_GRSCEN | DTSEC_IMASK_GTSCEN))
54 + if (pollTimeout == 100)
63 @@ -632,7 +649,12 @@ static t_Error DtsecSetTxPauseFrames(t_H
64 " value should be greater than 320."));
65 #endif /* FM_BAD_TX_TS_IN_B_2_B_ERRATA_DTSEC_A003 */
67 + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
69 fman_dtsec_set_tx_pause_frames(p_Dtsec->p_MemMap, pauseTime);
71 + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
76 @@ -653,8 +675,12 @@ static t_Error DtsecRxIgnoreMacPause(t_H
77 SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
78 SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
80 + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
82 fman_dtsec_handle_rx_pause(p_Dtsec->p_MemMap, accept_pause);
84 + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
89 @@ -787,8 +813,13 @@ static t_Error DtsecModifyMacAddress (t_
90 /* Initialize MAC Station Address registers (1 & 2) */
91 /* Station address have to be swapped (big endian to little endian */
92 p_Dtsec->addr = ENET_ADDR_TO_UINT64(*p_EnetAddr);
94 + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
96 fman_dtsec_set_mac_address(p_Dtsec->p_MemMap, (uint8_t *)(*p_EnetAddr));
98 + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
103 @@ -1076,8 +1107,12 @@ static t_Error DtsecSetWakeOnLan(t_Handl
104 SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
105 SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
107 + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
109 fman_dtsec_set_wol(p_Dtsec->p_MemMap, en);
111 + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
116 @@ -1098,11 +1133,15 @@ static t_Error DtsecAdjustLink(t_Handle
117 enet_speed = (enum enet_speed) ENET_SPEED_FROM_MODE(p_Dtsec->enetMode);
118 p_Dtsec->halfDuplex = !fullDuplex;
120 + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
122 err = fman_dtsec_adjust_link(p_Dtsec->p_MemMap, enet_interface, enet_speed, fullDuplex);
125 RETURN_ERROR(MAJOR, E_CONFLICT, ("Ethernet interface does not support Half Duplex mode"));
127 + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);