From 2b3d05ed1cb560b3a0b0721435c2fd73a19bd9bc Mon Sep 17 00:00:00 2001 From: Iordache Florinel-R70177 Date: Mon, 29 May 2017 09:25:24 +0300 Subject: [PATCH] sdk_fman: DPAA-dTSEC ports fail to work when link changes Signed-off-by: Iordache Florinel-R70177 --- .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c | 57 ++++++++++++++++++---- 1 file changed, 48 insertions(+), 9 deletions(-) --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c @@ -386,6 +386,7 @@ static void FreeInitResources(t_Dtsec *p static t_Error GracefulStop(t_Dtsec *p_Dtsec, e_CommMode mode) { struct dtsec_regs *p_MemMap; + int pollTimeout = 0; ASSERT_COND(p_Dtsec); @@ -408,16 +409,32 @@ static t_Error GracefulStop(t_Dtsec *p_D } if (mode & e_COMM_MODE_TX) -#if defined(FM_GTS_ERRATA_DTSEC_A004) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012) - if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2) - DBG(INFO, ("GTS not supported due to DTSEC_A004 errata.")); -#else /* not defined(FM_GTS_ERRATA_DTSEC_A004) ||... */ -#ifdef FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 - DBG(INFO, ("GTS not supported due to DTSEC_A0014 errata.")); -#else /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */ + { +#if defined(FM_GTS_ERRATA_DTSEC_A004) + if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2) + DBG(INFO, ("GTS not supported due to DTSEC_A004 errata.")); +#else /* not defined(FM_GTS_ERRATA_DTSEC_A004) */ + fman_dtsec_stop_tx(p_MemMap); -#endif /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */ -#endif /* defined(FM_GTS_ERRATA_DTSEC_A004) ||... */ + +#if defined(FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012) + XX_UDelay(10); +#endif /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 || FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012 */ +#endif /* defined(FM_GTS_ERRATA_DTSEC_A004) */ + } + + /* Poll GRSC/GTSC bits in IEVENT register until both are set */ +#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) + XX_UDelay(10); +#else + while (fman_dtsec_get_event(p_MemMap, DTSEC_IMASK_GRSCEN | DTSEC_IMASK_GTSCEN) != (DTSEC_IMASK_GRSCEN | DTSEC_IMASK_GTSCEN)) + { + if (pollTimeout == 100) + break; + XX_UDelay(1); + pollTimeout++; + } +#endif return E_OK; } @@ -632,7 +649,12 @@ static t_Error DtsecSetTxPauseFrames(t_H " value should be greater than 320.")); #endif /* FM_BAD_TX_TS_IN_B_2_B_ERRATA_DTSEC_A003 */ + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX); + fman_dtsec_set_tx_pause_frames(p_Dtsec->p_MemMap, pauseTime); + + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX); + return E_OK; } @@ -653,8 +675,12 @@ static t_Error DtsecRxIgnoreMacPause(t_H SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE); SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE); + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX); + fman_dtsec_handle_rx_pause(p_Dtsec->p_MemMap, accept_pause); + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX); + return E_OK; } @@ -787,8 +813,13 @@ static t_Error DtsecModifyMacAddress (t_ /* Initialize MAC Station Address registers (1 & 2) */ /* Station address have to be swapped (big endian to little endian */ p_Dtsec->addr = ENET_ADDR_TO_UINT64(*p_EnetAddr); + + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX); + fman_dtsec_set_mac_address(p_Dtsec->p_MemMap, (uint8_t *)(*p_EnetAddr)); + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX); + return E_OK; } @@ -1076,8 +1107,12 @@ static t_Error DtsecSetWakeOnLan(t_Handl SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE); SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE); + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX); + fman_dtsec_set_wol(p_Dtsec->p_MemMap, en); + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX); + return E_OK; } @@ -1098,11 +1133,15 @@ static t_Error DtsecAdjustLink(t_Handle enet_speed = (enum enet_speed) ENET_SPEED_FROM_MODE(p_Dtsec->enetMode); p_Dtsec->halfDuplex = !fullDuplex; + GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX); + err = fman_dtsec_adjust_link(p_Dtsec->p_MemMap, enet_interface, enet_speed, fullDuplex); if (err == -EINVAL) RETURN_ERROR(MAJOR, E_CONFLICT, ("Ethernet interface does not support Half Duplex mode")); + GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX); + return (t_Error)err; } d='n50' href='#n50'>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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326