Solution by OronSH.
We claim the solutions are given by the following: Either f(x)=21 for all x, or let S be a subfield of R. Let {ai} be a Hamel basis of R over S. Then for each ai, force f(ai)∈S and for ki∈S we have f(∑kiai)=∑kif(ai). To see that these work, if f(x)=21 then both sides are 21, otherwise we will get that f is additive, has range ⊆S, and that f(kx)=kf(x) for any k∈S, hence f(xf(x)+yf(x))=f(x+y)f(x)=f(x)2+f(x)f(y) as desired.
Now we show these are the only solutions. Denote the assertion by P(x,y). Taking P(0,0) gives f(0)=2f(0)2, so f(0)=21 or f(0)=0. Taking P(x,−x) and P(−x,x) give f(0)=f(x)2+f(x)f(−x)=f(−x)2+f(x)f(−x), hence f(x)=±f(−x) and hence f(0)=0 or 2f(x)2. If f(0)=21, then we get f(x)=±21 for all x, however f(x)=−21 fails by P(0,y). Hence we get the f(x)=21 solution here.
Otherwise, f(0)=0. Then P(x,−x)+P(−x,x) gives (f(x)+f(−x))2=0, hence f is odd.
Suppose there exist a,b such that f(a)=f(b). Taking P(a,k−a) and P(b,k−b) gives f(kf(a))=f(a)2+f(a)f(k−a)=f(b)2+f(b)f(k−b), hence f(a)=f(b)=0 or f(k−a)=f(k−b), the latter of which implies f is periodic with period a−b.
Take P(x,0) to get f(xf(x))=f(x)2. Now suppose that f(r)=0 for some r. Then if f(x)=0 we get from P(x,r) that f(xf(x)+rf(x))=f(x)2=f(xf(x))=0, hence rf(x) is a period of f for all x.
Suppose f(x)=0. Note that if we set xf(x)+yf(x)=x, then from P(x,y) we get f(x)+f(y)=1. Hence the range of f is symmetric over 21, except one is not necessarily in the range.
Suppose now that f is not constantly zero, so pick x with f(x)=0. Then if r is a root of f, then rf(x) is a period, but 1−f(x) is also in the range, hence r−rf(x) is also a period. Thus r is a period. In particular f(nr)=0 for all n∈Z.
Now take P(x,−2x) to get f(−xf(x))=f(x)2+f(x)f(−2x), but by oddness this becomes −f(xf(x))=f(x)2−f(x)f(2x). We have f(xf(x))=f(x)2, so plugging in we get either f(2x)=2f(x) or f(x)=0. However if f(x)=0 then f(2x)=0 by above, hence f(2x)=2f(x) always. In particular, if k is in the range, then so are 2k and 2k.
Let S be the range of f. We claim S is a field. To do this, suppose a,b=0∈S. We can find x,y with f(x)=b and f(xf(x)+yf(x))=a, since the inside of the latter spans all real numbers. This then gives f(y)=ba−b. Next, note that 2b∈S, and taking f(x)=2b,f(y)=ba−b gives f(xf(x)+yf(x))=2a+2b2. Hence half of this which is a+b2 is also in S. Now we can find x,y with f(x)=b and f(xf(x)+yf(x))=a+b2, which gives f(y)=ba upon plugging in. Hence S is closed under division.
In particular a=b gives 1∈S, hence a=1 gives b1∈S, and then we have 1/ba=ab∈S, hence S is closed under multiplication as well. Additionally, S is closed under addition since when a,b=0 we get that for f(x)=a,f(y)=b we have a+b=f(x)f(xf(x)+yf(x))∈S. From f odd we get S is closed under subtraction, hence S is a field as desired.
Suppose now that b is in the range, with f(a)=b, and that b=1. Taking P(a,y) gives f(ab+by)=b2+bf(y). Next P(a,ba−a) gives f(ba−a)=1−b.
Let c be such that f(c)=1. Then P(c,y) gives f(c+y)=1+f(y). Hence, setting y=−a gives f(c−a)=1+f(−a)=1−f(a)=1−b. Hence from above we have that c−ba is a period of f, hence 1+f(y)=f(c+y)=f(ba+y).
Now P(a,ba+y) gives f(ab+a+by)=b2+b+f(y). However this equals f(ab+by)+b. Since ab+by takes on any real value, we get f(x+a)=f(x)+b for all x. Hence f(ab+by)=b2+bf(y)=bf(a+y). Since a+y takes on any real value, we thus have that for any k∈S we have f(kx)=kf(x).
Hence when f(x)=0 we get f(xf(x)+yf(x))=f(x+y)f(x)=f(x)2+f(x)f(y), so f(x+y)=f(x)+f(y). This is true when f(x)=0 as well, since then x is a period. Hence f is additive.
Thus if we take some Hamel basis {ai} of R over S, we see that f(ai)∈S by definition of S, and that f(∑kiai)=∑f(kiai)=∑kif(ai), giving our solution set as desired.