From patchwork Tue Jun 11 15:51:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leyi Rong X-Patchwork-Id: 54696 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B7B4B1C58A; Tue, 11 Jun 2019 17:55:07 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C6ABE1C365 for ; Tue, 11 Jun 2019 17:54:23 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jun 2019 08:54:23 -0700 X-ExtLoop1: 1 Received: from lrong-srv-03.sh.intel.com ([10.67.119.177]) by orsmga001.jf.intel.com with ESMTP; 11 Jun 2019 08:54:22 -0700 From: Leyi Rong To: qi.z.zhang@intel.com Cc: dev@dpdk.org, Leyi Rong , Ben Shelton , Paul M Stillwell Jr Date: Tue, 11 Jun 2019 23:51:52 +0800 Message-Id: <20190611155221.2703-38-leyi.rong@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190611155221.2703-1-leyi.rong@intel.com> References: <20190604054248.68510-1-leyi.rong@intel.com> <20190611155221.2703-1-leyi.rong@intel.com> Subject: [dpdk-dev] [PATCH v2 37/66] net/ice/base: calculate rate limit burst size correctly X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. Signed-off-by: Ben Shelton Signed-off-by: Paul M Stillwell Jr Signed-off-by: Leyi Rong --- 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 0c1c18ba1..a72e72982 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 56f9977ab..e444dc880 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