From e4b73bee79bf6db14e9c98e09b48fd532b4b95df Mon Sep 17 00:00:00 2001 From: Leyi Rong Date: Wed, 19 Jun 2019 23:18:15 +0800 Subject: [PATCH] net/ice/base: fix rate limit burst size calculation When the MSB is not set, the lower 11 bits do not represent bytes, but chunks of 64 bytes. Adjust the rate limit burst size calculation accordingly, and update the comments to indicate the way the hardware actually works. Fixes: 93e84b1bfc92 ("net/ice/base: add basic Tx scheduler") Cc: stable@dpdk.org Signed-off-by: Ben Shelton Signed-off-by: Paul M Stillwell Jr Signed-off-by: Leyi Rong Acked-by: Qi Zhang --- drivers/net/ice/base/ice_sched.c | 17 ++++++++--------- drivers/net/ice/base/ice_sched.h | 14 ++++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c index 0c1c18ba14..a72e72982b 100644 --- a/drivers/net/ice/base/ice_sched.c +++ b/drivers/net/ice/base/ice_sched.c @@ -5060,16 +5060,15 @@ enum ice_status ice_cfg_rl_burst_size(struct ice_hw *hw, u32 bytes) if (bytes < ICE_MIN_BURST_SIZE_ALLOWED || bytes > ICE_MAX_BURST_SIZE_ALLOWED) return ICE_ERR_PARAM; - if (bytes <= ICE_MAX_BURST_SIZE_BYTE_GRANULARITY) { - /* byte granularity case */ + if (ice_round_to_num(bytes, 64) <= + ICE_MAX_BURST_SIZE_64_BYTE_GRANULARITY) { + /* 64 byte granularity case */ /* Disable MSB granularity bit */ - burst_size_to_prog = ICE_BYTE_GRANULARITY; - /* round number to nearest 256 granularity */ - bytes = ice_round_to_num(bytes, 256); - /* check rounding doesn't go beyond allowed */ - if (bytes > ICE_MAX_BURST_SIZE_BYTE_GRANULARITY) - bytes = ICE_MAX_BURST_SIZE_BYTE_GRANULARITY; - burst_size_to_prog |= (u16)bytes; + burst_size_to_prog = ICE_64_BYTE_GRANULARITY; + /* round number to nearest 64 byte granularity */ + bytes = ice_round_to_num(bytes, 64); + /* The value is in 64 byte chunks */ + burst_size_to_prog |= (u16)(bytes / 64); } else { /* k bytes granularity case */ /* Enable MSB granularity bit */ diff --git a/drivers/net/ice/base/ice_sched.h b/drivers/net/ice/base/ice_sched.h index 56f9977abf..e444dc880d 100644 --- a/drivers/net/ice/base/ice_sched.h +++ b/drivers/net/ice/base/ice_sched.h @@ -13,14 +13,16 @@ #define ICE_SCHED_INVAL_LAYER_NUM 0xFF /* Burst size is a 12 bits register that is configured while creating the RL * profile(s). MSB is a granularity bit and tells the granularity type - * 0 - LSB bits are in bytes granularity + * 0 - LSB bits are in 64 bytes granularity * 1 - LSB bits are in 1K bytes granularity */ -#define ICE_BYTE_GRANULARITY 0 -#define ICE_KBYTE_GRANULARITY 0x800 -#define ICE_MIN_BURST_SIZE_ALLOWED 1 /* In Bytes */ -#define ICE_MAX_BURST_SIZE_ALLOWED (2047 * 1024) /* In Bytes */ -#define ICE_MAX_BURST_SIZE_BYTE_GRANULARITY 2047 /* In Bytes */ +#define ICE_64_BYTE_GRANULARITY 0 +#define ICE_KBYTE_GRANULARITY BIT(11) +#define ICE_MIN_BURST_SIZE_ALLOWED 64 /* In Bytes */ +#define ICE_MAX_BURST_SIZE_ALLOWED \ + ((BIT(11) - 1) * 1024) /* In Bytes */ +#define ICE_MAX_BURST_SIZE_64_BYTE_GRANULARITY \ + ((BIT(11) - 1) * 64) /* In Bytes */ #define ICE_MAX_BURST_SIZE_KBYTE_GRANULARITY ICE_MAX_BURST_SIZE_ALLOWED #define ICE_RL_PROF_FREQUENCY 446000000 -- 2.20.1