KSZ8863MLL issue - suggestions on resolving
Not sure this applies without a full schematic and chip specs, but you need to be careful with IO operations like this if the receiver of the IO pin is edge detecting.

I have had issues in the past when toggling an output pin, especially when it's a change from input to output or vica-versa, where a race condition occurs during the change.

When that happens you can generate a very small (nS) pulse on the pin that you won't notice on the scope. However, some receiving devices MAY see it as a clock edge on the signal. Others may not.

It can be a real head scratcher to figure out. 

May not be your problem, but it is somewhere to look if everything else is proven to be working nominally.

BTW: If it is the latter, something like switching a couple of lines of code can often fix it. If not you may need to make the signal synchronous instead of asynchronous.