Foam in the hydraulic fluid will cause all sorts of problems. Think of the foam as a sponge while it looks like a solid object ,it will compress to a faction of it's size. Foam also does not flow well through the hoses.
Foam is caused by air or water contamination of the fluid. There could be an air leak in the suction line, clogged strainer in the tank, low fluid level,water in the fluid, or wrong fluid.
Find the cause of the foaming first. Foam can damage a pump quite quickly.