From: Andrew Rybchenko Date: Thu, 16 Nov 2017 08:04:12 +0000 (+0000) Subject: net/sfc/base: more accurately calculate number of PS credits X-Git-Tag: spdx-start~661 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ede62b5a56ff9c218b8a3eabdd6bbd466bcee903;p=dpdk.git net/sfc/base: more accurately calculate number of PS credits Maximum number of packets per 64k buffer should be rounded up when calculating number of credits by event queue size. Signed-off-by: Andrew Rybchenko --- diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c index 946efeb6b8..2c6edf3f46 100644 --- a/drivers/net/sfc/base/ef10_ev.c +++ b/drivers/net/sfc/base/ef10_ev.c @@ -1370,7 +1370,7 @@ ef10_ev_rxlabel_init( eersp->eers_rx_packed_stream = packed_stream; if (packed_stream) { eersp->eers_rx_packed_stream_credits = (eep->ee_mask + 1) / - (EFX_RX_PACKED_STREAM_MEM_PER_CREDIT / + EFX_DIV_ROUND_UP(EFX_RX_PACKED_STREAM_MEM_PER_CREDIT, EFX_RX_PACKED_STREAM_MIN_PACKET_SPACE); EFSYS_ASSERT3U(eersp->eers_rx_packed_stream_credits, !=, 0); /* diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h index bf17aba371..d7ce0b56ae 100644 --- a/drivers/net/sfc/base/efx.h +++ b/drivers/net/sfc/base/efx.h @@ -48,6 +48,9 @@ extern "C" { #define EFX_FIELD_OFFSET(_type, _field) \ ((size_t) &(((_type *)0)->_field)) +/* The macro expands divider twice */ +#define EFX_DIV_ROUND_UP(_n, _d) (((_n) + (_d) - 1) / (_d)) + /* Return codes */ typedef __success(return == 0) int efx_rc_t;