net: qed: fix left elements count calculation
authorAlexander Lobakin <alobakin@marvell.com>
Tue, 23 Jun 2020 13:51:29 +0000 (16:51 +0300)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:38:42 +0000 (15:38 -0400)
commitea6eb20cfeb4d94dea14c740812cca64bc0b89d4
treed4470072b4005670f01d8e38c71d479d462ae4fd
parent79eb4f02c23a090b8c06002d33392c2191fb6110
net: qed: fix left elements count calculation

[ Upstream commit 97dd1abd026ae4e6a82fa68645928404ad483409 ]

qed_chain_get_element_left{,_u32} returned 0 when the difference
between producer and consumer page count was equal to the total
page count.
Fix this by conditional expanding of producer value (vs
unconditional). This allowed to eliminate normalizaton against
total page count, which was the cause of this bug.

Misc: replace open-coded constants with common defines.

Fixes: a91eb52abb50 ("qed: Revisit chain implementation")
Signed-off-by: Alexander Lobakin <alobakin@marvell.com>
Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/qed/qed_chain.h