]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: dsa: microchip: add ksz_setup_tc_mode() function
authorOleksij Rempel <o.rempel@pengutronix.de>
Fri, 10 Mar 2023 09:08:08 +0000 (10:08 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Mar 2023 08:00:34 +0000 (08:00 +0000)
Add ksz_setup_tc_mode() to make queue scheduling and shaping
configuration more visible.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/ksz_common.h

index 729b36eeb2c46acacf9312f1af6fd7a68f40455e..11f20501524f237851a0c1ce673e23d4dc3a9a48 100644 (file)
 #include "ksz9477.h"
 #include "lan937x.h"
 
-#define KSZ_CBS_ENABLE ((MTI_SCHEDULE_STRICT_PRIO << MTI_SCHEDULE_MODE_S) | \
-                       (MTI_SHAPING_SRP << MTI_SHAPING_S))
-#define KSZ_CBS_DISABLE ((MTI_SCHEDULE_WRR << MTI_SCHEDULE_MODE_S) |\
-                        (MTI_SHAPING_OFF << MTI_SHAPING_S))
 #define MIB_COUNTER_NUM 0x20
 
 struct ksz_stats_raw {
@@ -3091,6 +3087,14 @@ static int cinc_cal(s32 idle_slope, s32 send_slope, u32 *bw)
        return 0;
 }
 
+static int ksz_setup_tc_mode(struct ksz_device *dev, int port, u8 scheduler,
+                            u8 shaper)
+{
+       return ksz_pwrite8(dev, port, REG_PORT_MTI_QUEUE_CTRL_0,
+                          FIELD_PREP(MTI_SCHEDULE_MODE_M, scheduler) |
+                          FIELD_PREP(MTI_SHAPING_M, shaper));
+}
+
 static int ksz_setup_tc_cbs(struct dsa_switch *ds, int port,
                            struct tc_cbs_qopt_offload *qopt)
 {
@@ -3110,8 +3114,8 @@ static int ksz_setup_tc_cbs(struct dsa_switch *ds, int port,
                return ret;
 
        if (!qopt->enable)
-               return ksz_pwrite8(dev, port, REG_PORT_MTI_QUEUE_CTRL_0,
-                                  KSZ_CBS_DISABLE);
+               return ksz_setup_tc_mode(dev, port, MTI_SCHEDULE_WRR,
+                                        MTI_SHAPING_OFF);
 
        /* High Credit */
        ret = ksz_pwrite16(dev, port, REG_PORT_MTI_HI_WATER_MARK,
@@ -3136,8 +3140,8 @@ static int ksz_setup_tc_cbs(struct dsa_switch *ds, int port,
                        return ret;
        }
 
-       return ksz_pwrite8(dev, port, REG_PORT_MTI_QUEUE_CTRL_0,
-                          KSZ_CBS_ENABLE);
+       return ksz_setup_tc_mode(dev, port, MTI_SCHEDULE_STRICT_PRIO,
+                                MTI_SHAPING_SRP);
 }
 
 static int ksz_setup_tc(struct dsa_switch *ds, int port,
index d2d5761d58e9b4c9ad18d062267fb6de9b319a86..7d87c9a79fb47118a18c652e8ffbf3b3dfbd7870 100644 (file)
@@ -654,12 +654,10 @@ static inline int is_lan937x(struct ksz_device *dev)
 
 #define REG_PORT_MTI_QUEUE_CTRL_0      0x0914
 
-#define MTI_SCHEDULE_MODE_M            0x3
-#define MTI_SCHEDULE_MODE_S            6
+#define MTI_SCHEDULE_MODE_M            GENMASK(7, 6)
 #define MTI_SCHEDULE_STRICT_PRIO       0
 #define MTI_SCHEDULE_WRR               2
-#define MTI_SHAPING_M                  0x3
-#define MTI_SHAPING_S                  4
+#define MTI_SHAPING_M                  GENMASK(5, 4)
 #define MTI_SHAPING_OFF                        0
 #define MTI_SHAPING_SRP                        1
 #define MTI_SHAPING_TIME_AWARE         2