Typically dogs do not chew their food like we do. In carnivores they break off chunks the right size to swallow and then their stomach acids break them down. So often the dogs just 'inhale' their dry food.
White foam is usually foamy saliva which a dog produces when its feeling nauseous.
If the food is coming right back out as if no digestion at all happened it is possible the food is not making it to the stomach and the dog might be trapping the food in the esophagus due to a problem there. You can read about this here
It may also be he has a worm infection and is vomiting becasue the worms are moving around when he swallows food making him feel queasy.
And being a puppy he may have swallowed a non food item that is making him vomit.
I'd plan a vet check up for him.
Hope this helps you!