net: ena: fix napi handler misbehavior when the napi budget is zero
authorNetanel Belgazal <netanel@amazon.com>
Tue, 10 Dec 2019 11:27:44 +0000 (11:27 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 Jan 2020 13:00:11 +0000 (14:00 +0100)
commita6585c5b85341072f861f1b15e6378ddaf3c27e1
treeff66a6cd8b170d88c7cf61ea22d208644b7f805e
parenta6d311f2e79847424ded55f81f60fc5af1c1117d
net: ena: fix napi handler misbehavior when the napi budget is zero

[ Upstream commit 24dee0c7478d1a1e00abdf5625b7f921467325dc ]

In netpoll the napi handler could be called with budget equal to zero.
Current ENA napi handler doesn't take that into consideration.

The napi handler handles Rx packets in a do-while loop.
Currently, the budget check happens only after decrementing the
budget, therefore the napi handler, in rare cases, could run over
MAX_INT packets.

In addition to that, this moves all budget related variables to int
calculation and stop mixing u32 to avoid ambiguity

Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: Netanel Belgazal <netanel@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/amazon/ena/ena_netdev.c