e17c2a7a4dc62a6601fef68689a7f5fdab1dcada
[openwrt/staging/pepe2k.git] /
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
5
6 Signed-off-by: Iordache Florinel-R70177 <florinel.iordache@nxp.com>
7 ---
8 .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c | 57 ++++++++++++++++++----
9 1 file changed, 48 insertions(+), 9 deletions(-)
10
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)
15 {
16 struct dtsec_regs *p_MemMap;
17 + int pollTimeout = 0;
18
19 ASSERT_COND(p_Dtsec);
20
21 @@ -408,16 +409,32 @@ static t_Error GracefulStop(t_Dtsec *p_D
22 }
23
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 */
32 + {
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) */
37 +
38 fman_dtsec_stop_tx(p_MemMap);
39 -#endif /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */
40 -#endif /* defined(FM_GTS_ERRATA_DTSEC_A004) ||... */
41 +
42 +#if defined(FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012)
43 + XX_UDelay(10);
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) */
46 + }
47 +
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)
50 + XX_UDelay(10);
51 +#else
52 + while (fman_dtsec_get_event(p_MemMap, DTSEC_IMASK_GRSCEN | DTSEC_IMASK_GTSCEN) != (DTSEC_IMASK_GRSCEN | DTSEC_IMASK_GTSCEN))
53 + {
54 + if (pollTimeout == 100)
55 + break;
56 + XX_UDelay(1);
57 + pollTimeout++;
58 + }
59 +#endif
60
61 return E_OK;
62 }
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 */
66
67 + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
68 +
69 fman_dtsec_set_tx_pause_frames(p_Dtsec->p_MemMap, pauseTime);
70 +
71 + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
72 +
73 return E_OK;
74 }
75
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);
79
80 + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
81 +
82 fman_dtsec_handle_rx_pause(p_Dtsec->p_MemMap, accept_pause);
83
84 + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
85 +
86 return E_OK;
87 }
88
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);
93 +
94 + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
95 +
96 fman_dtsec_set_mac_address(p_Dtsec->p_MemMap, (uint8_t *)(*p_EnetAddr));
97
98 + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
99 +
100 return E_OK;
101 }
102
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);
106
107 + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
108 +
109 fman_dtsec_set_wol(p_Dtsec->p_MemMap, en);
110
111 + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
112 +
113 return E_OK;
114 }
115
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;
119
120 + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
121 +
122 err = fman_dtsec_adjust_link(p_Dtsec->p_MemMap, enet_interface, enet_speed, fullDuplex);
123
124 if (err == -EINVAL)
125 RETURN_ERROR(MAJOR, E_CONFLICT, ("Ethernet interface does not support Half Duplex mode"));
126
127 + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
128 +
129 return (t_Error)err;
130 }
131