kernel: add mv88e61xx switch port-mirroring support
[openwrt/staging/lynxis.git] / target / linux / generic / files / drivers / net / phy / mvsw61xx.h
index dbc6c92a444a608de5fd835dcbdbf91db909a2ba..545e2dd660eaec35d19d961804dbec00e89b8f53 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 2014 Claudio Leite <leitec@staticky.com>
  * Copyright (c) 2014 Nikita Nazarenko <nnazarenko@radiofid.com>
  *
- * Based on code (c) 2008 Felix Fietkau <nbd@openwrt.org>
+ * Based on code (c) 2008 Felix Fietkau <nbd@nbd.name>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License v2 as published by the
@@ -48,6 +48,14 @@ enum {
        MV_PORT_STATUS_LINK             = (1 << 11),
 };
 
+enum {
+       MV_PORT_STATUS_CMODE_100BASE_X  = 0x8,
+       MV_PORT_STATUS_CMODE_1000BASE_X = 0x9,
+       MV_PORT_STATUS_CMODE_SGMII      = 0xa,
+};
+
+#define MV_PORT_STATUS_CMODE_MASK      0xf
+
 enum {
        MV_PORT_STATUS_SPEED_10         = 0x00,
        MV_PORT_STATUS_SPEED_100        = 0x01,
@@ -157,11 +165,14 @@ enum {
        MV_GLOBAL_VTU_DATA1             = 0x07,
        MV_GLOBAL_VTU_DATA2             = 0x08,
        MV_GLOBAL_VTU_DATA3             = 0x09,
+       MV_GLOBAL_MONITOR_CTRL          = 0x1a,
        MV_GLOBAL_CONTROL2              = 0x1c,
 };
 #define MV_GLOBALREG(_type) MV_SWITCH_GLOBAL, MV_GLOBAL_##_type
 
 enum {
+       MV_GLOBAL2_SMI_OP               = 0x18,
+       MV_GLOBAL2_SMI_DATA             = 0x19,
        MV_GLOBAL2_SDET_POLARITY        = 0x1d,
 };
 #define MV_GLOBAL2REG(_type) MV_SWITCH_GLOBAL2, MV_GLOBAL2_##_type
@@ -222,6 +233,9 @@ enum {
 #define MV_IDENT_VALUE_6176            0x1760
 #define MV_IDENT_STR_6176              "MV88E6176"
 
+#define MV_IDENT_VALUE_6352            0x3520
+#define MV_IDENT_STR_6352              "MV88E6352"
+
 #define MV_PVID_MASK                   0x0fff
 
 #define MV_FDB_HI_MASK                 0x00ff
@@ -229,6 +243,29 @@ enum {
 #define MV_FDB_HI_SHIFT                        4
 #define MV_FDB_LO_SHIFT                        12
 
+#define MV_MIRROR_RX_DEST_MASK         0xf000
+#define MV_MIRROR_TX_DEST_MASK         0x0f00
+#define MV_MIRROR_RX_DEST_SHIFT                12
+#define MV_MIRROR_TX_DEST_SHIFT                8
+
+#define MV_MIRROR_RX_SRC_SHIFT         4
+#define MV_MIRROR_RX_SRC_MASK          (1 << MV_MIRROR_RX_SRC_SHIFT)
+#define MV_MIRROR_TX_SRC_SHIFT         5
+#define MV_MIRROR_TX_SRC_MASK          (1 << MV_MIRROR_TX_SRC_SHIFT)
+
+/* Marvell Specific PHY register */
+#define MII_MV_SPEC_CTRL               16
+enum {
+       MV_SPEC_MDI_CROSS_AUTO          = (0x6 << 4),
+       MV_SPEC_ENERGY_DETECT           = (0x3 << 8),
+       MV_SPEC_DOWNSHIFT_COUNTER       = (0x3 << 12),
+};
+
+#define MII_MV_PAGE                    22
+
+#define MV_REG_FIBER_SERDES            0xf
+#define MV_PAGE_FIBER_SERDES           0x1
+
 struct mvsw61xx_state {
        struct switch_dev dev;
        struct mii_bus *bus;
@@ -258,6 +295,12 @@ struct mvsw61xx_state {
                u32 port_sstate;
        } vlans[MV_VLANS];
 
+       /* mirroring */
+       bool mirror_rx;
+       bool mirror_tx;
+       int source_port;
+       int monitor_port;
+
        char buf[128];
 };