How many solutions are there to $F(n,m)=n^2+nm+m^2 = Q$? Let $n,m$ be two positive integers, we consider:
$$F(n,m)=n^2+nm+m^2$$
Let $Q$ be one value reach by $F(n,m)$.
How many different pairs $(n,m)$ verify $F(n,m)=Q$?
 A: As it turns out, we can give a complete answer to this question.  The exact number of solutions depends on the prime factorization of $Q$  Specifically, it is a function of the exponents of the prime factors which are congruent to $1$ mod $3$, with the condition that all the factors congruent to $2$ modulo $3$ have their prime factors appear with even multiplicity.
Note:  I have not yet provided a proof, the result that primes of the form $1+3k$ can be represented is a theorem of Jacobi.
Let $$Q=\prod_i q_i^{\alpha_i} \prod_i p_i^{\beta_i}$$ where the $q_i$ are $1$ mod $3$ and the $p_i$ are $2$ mod $3$. Our equation $n^2+nm+m^2$ has solutions if and only if each $\beta_i$ is even.
Proof:  Take the equation modulo $3$.  By case analysis for $n,m$ the right hand side cannot be congruent to $2$, and hence the statement follows.
Remark:  Notice the following similarity to the sum of squares problem (points on a circle). 
The Answer:    Suppose that as before $$Q=\prod_i q_i^{\alpha_i} \prod_i p_i^{\beta_i}$$ where the $q_i$ are $1$ mod $3$ and the $p_i$ are $2$ mod $3$.  Suppose as well that all of the $\beta_i$ are even.  (Otherwise we can have no solutions)
Let $$B=(\alpha_1+1)(\alpha_2+1)\cdots(\alpha_n+1).$$ Then the number of non-negative integer solutions to $$m^2+mn+n^2=Q$$ is exactly $$\left\lceil\frac{B}{2}\right\rceil.$$
(Again notice the similarity to the sum of squares function)
In particular, if $l(Q)$ is the number of representations where $n,m$ are any integers, (that is positive or negative) then $$l(Q)=2B.$$
Hope that helps.
