]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: dsa: mv88e6xxx: Split monitor port configuration
authorIwan R Timmer <irtimmer@gmail.com>
Thu, 7 Nov 2019 21:11:13 +0000 (22:11 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Nov 2019 20:51:03 +0000 (12:51 -0800)
Separate the configuration of the egress and ingress monitor port.
This allows the port mirror functionality to do ingress and egress
port mirroring to separate ports.

Signed-off-by: Iwan R Timmer <irtimmer@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/chip.h
drivers/net/dsa/mv88e6xxx/global1.c
drivers/net/dsa/mv88e6xxx/global1.h

index 0dbe6c8b9dc09897a5cf963e1679bd9259030fee..dfca0ec35145b57db697e6deb7299baa29a20a27 100644 (file)
@@ -2390,7 +2390,14 @@ static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
 
                if (chip->info->ops->set_egress_port) {
                        err = chip->info->ops->set_egress_port(chip,
-                                                              upstream_port);
+                                               MV88E6XXX_EGRESS_DIR_INGRESS,
+                                               upstream_port);
+                       if (err)
+                               return err;
+
+                       err = chip->info->ops->set_egress_port(chip,
+                                               MV88E6XXX_EGRESS_DIR_EGRESS,
+                                               upstream_port);
                        if (err)
                                return err;
                }
index 65ce09bdcbcf3000612a2556e4e4c51035265d0a..9fc93b1a9f74d2483300dae0983b846486ac7abd 100644 (file)
@@ -33,6 +33,11 @@ enum mv88e6xxx_egress_mode {
        MV88E6XXX_EGRESS_MODE_ETHERTYPE,
 };
 
+enum mv88e6xxx_egress_direction {
+        MV88E6XXX_EGRESS_DIR_INGRESS,
+        MV88E6XXX_EGRESS_DIR_EGRESS,
+};
+
 enum mv88e6xxx_frame_mode {
        MV88E6XXX_FRAME_MODE_NORMAL,
        MV88E6XXX_FRAME_MODE_DSA,
@@ -465,7 +470,9 @@ struct mv88e6xxx_ops {
        int (*stats_get_stats)(struct mv88e6xxx_chip *chip,  int port,
                               uint64_t *data);
        int (*set_cpu_port)(struct mv88e6xxx_chip *chip, int port);
-       int (*set_egress_port)(struct mv88e6xxx_chip *chip, int port);
+       int (*set_egress_port)(struct mv88e6xxx_chip *chip,
+                              enum mv88e6xxx_egress_direction direction,
+                              int port);
 
 #define MV88E6XXX_CASCADE_PORT_NONE            0xe
 #define MV88E6XXX_CASCADE_PORT_MULTIPLE                0xf
index 25ec4c0ac589ae04f76d9da521546d8a18dda9b9..36b88db22946c71880c1a6e371b22cfc63f4fc69 100644 (file)
@@ -263,7 +263,9 @@ int mv88e6250_g1_ieee_pri_map(struct mv88e6xxx_chip *chip)
 /* Offset 0x1a: Monitor Control */
 /* Offset 0x1a: Monitor & MGMT Control on some devices */
 
-int mv88e6095_g1_set_egress_port(struct mv88e6xxx_chip *chip, int port)
+int mv88e6095_g1_set_egress_port(struct mv88e6xxx_chip *chip,
+                                enum mv88e6xxx_egress_direction direction,
+                                int port)
 {
        u16 reg;
        int err;
@@ -272,11 +274,20 @@ int mv88e6095_g1_set_egress_port(struct mv88e6xxx_chip *chip, int port)
        if (err)
                return err;
 
-       reg &= ~(MV88E6185_G1_MONITOR_CTL_INGRESS_DEST_MASK |
-                MV88E6185_G1_MONITOR_CTL_EGRESS_DEST_MASK);
-
-       reg |= port << __bf_shf(MV88E6185_G1_MONITOR_CTL_INGRESS_DEST_MASK) |
-               port << __bf_shf(MV88E6185_G1_MONITOR_CTL_EGRESS_DEST_MASK);
+       switch (direction) {
+       case MV88E6XXX_EGRESS_DIR_INGRESS:
+               reg &= MV88E6185_G1_MONITOR_CTL_INGRESS_DEST_MASK;
+               reg |= port <<
+                      __bf_shf(MV88E6185_G1_MONITOR_CTL_INGRESS_DEST_MASK);
+               break;
+       case MV88E6XXX_EGRESS_DIR_EGRESS:
+               reg &= MV88E6185_G1_MONITOR_CTL_EGRESS_DEST_MASK;
+               reg |= port <<
+                      __bf_shf(MV88E6185_G1_MONITOR_CTL_EGRESS_DEST_MASK);
+               break;
+       default:
+               return -EINVAL;
+       }
 
        return mv88e6xxx_g1_write(chip, MV88E6185_G1_MONITOR_CTL, reg);
 }
@@ -310,17 +321,24 @@ static int mv88e6390_g1_monitor_write(struct mv88e6xxx_chip *chip,
        return mv88e6xxx_g1_write(chip, MV88E6390_G1_MONITOR_MGMT_CTL, reg);
 }
 
-int mv88e6390_g1_set_egress_port(struct mv88e6xxx_chip *chip, int port)
+int mv88e6390_g1_set_egress_port(struct mv88e6xxx_chip *chip,
+                                enum mv88e6xxx_egress_direction direction,
+                                int port)
 {
        u16 ptr;
        int err;
 
-       ptr = MV88E6390_G1_MONITOR_MGMT_CTL_PTR_INGRESS_DEST;
-       err = mv88e6390_g1_monitor_write(chip, ptr, port);
-       if (err)
-               return err;
+       switch (direction) {
+       case MV88E6XXX_EGRESS_DIR_INGRESS:
+               ptr = MV88E6390_G1_MONITOR_MGMT_CTL_PTR_INGRESS_DEST;
+               break;
+       case MV88E6XXX_EGRESS_DIR_EGRESS:
+               ptr = MV88E6390_G1_MONITOR_MGMT_CTL_PTR_EGRESS_DEST;
+               break;
+       default:
+               return -EINVAL;
+       }
 
-       ptr = MV88E6390_G1_MONITOR_MGMT_CTL_PTR_EGRESS_DEST;
        err = mv88e6390_g1_monitor_write(chip, ptr, port);
        if (err)
                return err;
index 3421722758415f2c14b4998689846826ccacf90e..bc5a6b2bb1e48caa933e89aa77f382f33d62cc3e 100644 (file)
@@ -288,8 +288,12 @@ int mv88e6095_g1_stats_set_histogram(struct mv88e6xxx_chip *chip);
 int mv88e6390_g1_stats_set_histogram(struct mv88e6xxx_chip *chip);
 void mv88e6xxx_g1_stats_read(struct mv88e6xxx_chip *chip, int stat, u32 *val);
 int mv88e6xxx_g1_stats_clear(struct mv88e6xxx_chip *chip);
-int mv88e6095_g1_set_egress_port(struct mv88e6xxx_chip *chip, int port);
-int mv88e6390_g1_set_egress_port(struct mv88e6xxx_chip *chip, int port);
+int mv88e6095_g1_set_egress_port(struct mv88e6xxx_chip *chip,
+                                enum mv88e6xxx_egress_direction direction,
+                                int port);
+int mv88e6390_g1_set_egress_port(struct mv88e6xxx_chip *chip,
+                                enum mv88e6xxx_egress_direction direction,
+                                int port);
 int mv88e6095_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port);
 int mv88e6390_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port);
 int mv88e6390_g1_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip);