net/ice/base: fix rate limit burst size calculation
authorLeyi Rong <leyi.rong@intel.com>
Wed, 19 Jun 2019 15:18:15 +0000 (23:18 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 28 Jun 2019 18:31:48 +0000 (20:31 +0200)
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 <benjamin.h.shelton@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Leyi Rong <leyi.rong@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/ice/base/ice_sched.c
drivers/net/ice/base/ice_sched.h

index 0c1c18b..a72e729 100644 (file)
@@ -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 */
index 56f9977..e444dc8 100644 (file)
 #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