]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: microchip: move ksz8->masks to ksz_common
authorArun Ramadoss <arun.ramadoss@microchip.com>
Tue, 28 Jun 2022 17:13:24 +0000 (22:43 +0530)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 Jun 2022 12:47:59 +0000 (13:47 +0100)
This patch moves the ksz8->masks from ksz8795.c to ksz_common.c. The
mask will be dereferenced using dev->info->masks.

Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/microchip/ksz8.h
drivers/net/dsa/microchip/ksz8795.c
drivers/net/dsa/microchip/ksz9477_reg.h
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/ksz_common.h

index 465b91496ea04a36e81314d3a60d0e4b9d65c247..22a047761aa5491cdbe91a14e55d1e7eae3ab75d 100644 (file)
 #include <net/dsa.h>
 #include "ksz_common.h"
 
-enum ksz_masks {
-       PORT_802_1P_REMAPPING,
-       SW_TAIL_TAG_ENABLE,
-       MIB_COUNTER_OVERFLOW,
-       MIB_COUNTER_VALID,
-       VLAN_TABLE_FID,
-       VLAN_TABLE_MEMBERSHIP,
-       VLAN_TABLE_VALID,
-       STATIC_MAC_TABLE_VALID,
-       STATIC_MAC_TABLE_USE_FID,
-       STATIC_MAC_TABLE_FID,
-       STATIC_MAC_TABLE_OVERRIDE,
-       STATIC_MAC_TABLE_FWD_PORTS,
-       DYNAMIC_MAC_TABLE_ENTRIES_H,
-       DYNAMIC_MAC_TABLE_MAC_EMPTY,
-       DYNAMIC_MAC_TABLE_NOT_READY,
-       DYNAMIC_MAC_TABLE_ENTRIES,
-       DYNAMIC_MAC_TABLE_FID,
-       DYNAMIC_MAC_TABLE_SRC_PORT,
-       DYNAMIC_MAC_TABLE_TIMESTAMP,
-};
-
 enum ksz_shifts {
        VLAN_TABLE_MEMBERSHIP_S,
        VLAN_TABLE,
@@ -47,7 +25,6 @@ enum ksz_shifts {
 };
 
 struct ksz8 {
-       const u32 *masks;
        const u8 *shifts;
        void *priv;
 };
index deac3a40381e60361b34cd5b7a39bdfd4b46a636..0c72ec50c04d7ec87f3b734b3f559af3056c7282 100644 (file)
 #include "ksz8795_reg.h"
 #include "ksz8.h"
 
-static const u32 ksz8795_masks[] = {
-       [PORT_802_1P_REMAPPING]         = BIT(7),
-       [SW_TAIL_TAG_ENABLE]            = BIT(1),
-       [MIB_COUNTER_OVERFLOW]          = BIT(6),
-       [MIB_COUNTER_VALID]             = BIT(5),
-       [VLAN_TABLE_FID]                = GENMASK(6, 0),
-       [VLAN_TABLE_MEMBERSHIP]         = GENMASK(11, 7),
-       [VLAN_TABLE_VALID]              = BIT(12),
-       [STATIC_MAC_TABLE_VALID]        = BIT(21),
-       [STATIC_MAC_TABLE_USE_FID]      = BIT(23),
-       [STATIC_MAC_TABLE_FID]          = GENMASK(30, 24),
-       [STATIC_MAC_TABLE_OVERRIDE]     = BIT(26),
-       [STATIC_MAC_TABLE_FWD_PORTS]    = GENMASK(24, 20),
-       [DYNAMIC_MAC_TABLE_ENTRIES_H]   = GENMASK(6, 0),
-       [DYNAMIC_MAC_TABLE_MAC_EMPTY]   = BIT(8),
-       [DYNAMIC_MAC_TABLE_NOT_READY]   = BIT(7),
-       [DYNAMIC_MAC_TABLE_ENTRIES]     = GENMASK(31, 29),
-       [DYNAMIC_MAC_TABLE_FID]         = GENMASK(26, 20),
-       [DYNAMIC_MAC_TABLE_SRC_PORT]    = GENMASK(26, 24),
-       [DYNAMIC_MAC_TABLE_TIMESTAMP]   = GENMASK(28, 27),
-};
-
 static const u8 ksz8795_shifts[] = {
        [VLAN_TABLE_MEMBERSHIP_S]       = 7,
        [VLAN_TABLE]                    = 16,
@@ -60,28 +38,6 @@ static const u8 ksz8795_shifts[] = {
        [DYNAMIC_MAC_SRC_PORT]          = 24,
 };
 
-static const u32 ksz8863_masks[] = {
-       [PORT_802_1P_REMAPPING]         = BIT(3),
-       [SW_TAIL_TAG_ENABLE]            = BIT(6),
-       [MIB_COUNTER_OVERFLOW]          = BIT(7),
-       [MIB_COUNTER_VALID]             = BIT(6),
-       [VLAN_TABLE_FID]                = GENMASK(15, 12),
-       [VLAN_TABLE_MEMBERSHIP]         = GENMASK(18, 16),
-       [VLAN_TABLE_VALID]              = BIT(19),
-       [STATIC_MAC_TABLE_VALID]        = BIT(19),
-       [STATIC_MAC_TABLE_USE_FID]      = BIT(21),
-       [STATIC_MAC_TABLE_FID]          = GENMASK(29, 26),
-       [STATIC_MAC_TABLE_OVERRIDE]     = BIT(20),
-       [STATIC_MAC_TABLE_FWD_PORTS]    = GENMASK(18, 16),
-       [DYNAMIC_MAC_TABLE_ENTRIES_H]   = GENMASK(5, 0),
-       [DYNAMIC_MAC_TABLE_MAC_EMPTY]   = BIT(7),
-       [DYNAMIC_MAC_TABLE_NOT_READY]   = BIT(7),
-       [DYNAMIC_MAC_TABLE_ENTRIES]     = GENMASK(31, 28),
-       [DYNAMIC_MAC_TABLE_FID]         = GENMASK(19, 16),
-       [DYNAMIC_MAC_TABLE_SRC_PORT]    = GENMASK(21, 20),
-       [DYNAMIC_MAC_TABLE_TIMESTAMP]   = GENMASK(23, 22),
-};
-
 static u8 ksz8863_shifts[] = {
        [VLAN_TABLE_MEMBERSHIP_S]       = 16,
        [STATIC_MAC_FWD_PORTS]          = 16,
@@ -183,7 +139,6 @@ static void ksz8795_set_prio_queue(struct ksz_device *dev, int port, int queue)
 
 void ksz8_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt)
 {
-       struct ksz8 *ksz8 = dev->priv;
        const u32 *masks;
        const u8 *regs;
        u16 ctrl_addr;
@@ -191,7 +146,7 @@ void ksz8_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt)
        u8 check;
        int loop;
 
-       masks = ksz8->masks;
+       masks = dev->info->masks;
        regs = dev->info->regs;
 
        ctrl_addr = addr + dev->info->reg_mib_cnt * port;
@@ -220,7 +175,6 @@ void ksz8_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt)
 static void ksz8795_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
                              u64 *dropped, u64 *cnt)
 {
-       struct ksz8 *ksz8 = dev->priv;
        const u32 *masks;
        const u8 *regs;
        u16 ctrl_addr;
@@ -228,7 +182,7 @@ static void ksz8795_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
        u8 check;
        int loop;
 
-       masks = ksz8->masks;
+       masks = dev->info->masks;
        regs = dev->info->regs;
 
        addr -= dev->info->reg_mib_cnt;
@@ -391,12 +345,11 @@ static void ksz8_w_table(struct ksz_device *dev, int table, u16 addr, u64 data)
 
 static int ksz8_valid_dyn_entry(struct ksz_device *dev, u8 *data)
 {
-       struct ksz8 *ksz8 = dev->priv;
        int timeout = 100;
        const u32 *masks;
        const u8 *regs;
 
-       masks = ksz8->masks;
+       masks = dev->info->masks;
        regs = dev->info->regs;
 
        do {
@@ -431,7 +384,7 @@ int ksz8_r_dyn_mac_table(struct ksz_device *dev, u16 addr, u8 *mac_addr,
        int rc;
 
        shifts = ksz8->shifts;
-       masks = ksz8->masks;
+       masks = dev->info->masks;
        regs = dev->info->regs;
 
        ctrl_addr = IND_ACC_TABLE(TABLE_DYNAMIC_MAC | TABLE_READ) | addr;
@@ -492,7 +445,7 @@ int ksz8_r_sta_mac_table(struct ksz_device *dev, u16 addr,
        u64 data;
 
        shifts = ksz8->shifts;
-       masks = ksz8->masks;
+       masks = dev->info->masks;
 
        ksz8_r_table(dev, TABLE_STATIC_MAC, addr, &data);
        data_hi = data >> 32;
@@ -531,7 +484,7 @@ void ksz8_w_sta_mac_table(struct ksz_device *dev, u16 addr,
        u64 data;
 
        shifts = ksz8->shifts;
-       masks = ksz8->masks;
+       masks = dev->info->masks;
 
        data_lo = ((u32)alu->mac[2] << 24) |
                ((u32)alu->mac[3] << 16) |
@@ -562,7 +515,7 @@ static void ksz8_from_vlan(struct ksz_device *dev, u32 vlan, u8 *fid,
        const u32 *masks;
 
        shifts = ksz8->shifts;
-       masks = ksz8->masks;
+       masks = dev->info->masks;
 
        *fid = vlan & masks[VLAN_TABLE_FID];
        *member = (vlan & masks[VLAN_TABLE_MEMBERSHIP]) >>
@@ -578,7 +531,7 @@ static void ksz8_to_vlan(struct ksz_device *dev, u8 fid, u8 member, u8 valid,
        const u32 *masks;
 
        shifts = ksz8->shifts;
-       masks = ksz8->masks;
+       masks = dev->info->masks;
 
        *vlan = fid;
        *vlan |= (u16)member << shifts[VLAN_TABLE_MEMBERSHIP_S];
@@ -1237,11 +1190,10 @@ static void ksz8795_cpu_interface_select(struct ksz_device *dev, int port)
 void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port)
 {
        struct dsa_switch *ds = dev->ds;
-       struct ksz8 *ksz8 = dev->priv;
        const u32 *masks;
        u8 member;
 
-       masks = ksz8->masks;
+       masks = dev->info->masks;
 
        /* enable broadcast storm limit */
        ksz_port_cfg(dev, port, P_BCAST_STORM_CTRL, PORT_BROADCAST_STORM, true);
@@ -1274,14 +1226,13 @@ void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port)
 void ksz8_config_cpu_port(struct dsa_switch *ds)
 {
        struct ksz_device *dev = ds->priv;
-       struct ksz8 *ksz8 = dev->priv;
        struct ksz_port *p;
        const u32 *masks;
        const u8 *regs;
        u8 remote;
        int i;
 
-       masks = ksz8->masks;
+       masks = dev->info->masks;
        regs = dev->info->regs;
 
        /* Switch marks the maximum frame with extra byte as oversize. */
@@ -1422,10 +1373,8 @@ int ksz8_switch_init(struct ksz_device *dev)
        dev->port_mask = (BIT(dev->phy_port_cnt) - 1) | dev->info->cpu_ports;
 
        if (ksz_is_ksz88x3(dev)) {
-               ksz8->masks = ksz8863_masks;
                ksz8->shifts = ksz8863_shifts;
        } else {
-               ksz8->masks = ksz8795_masks;
                ksz8->shifts = ksz8795_shifts;
        }
 
index 2cbbfda22c67ce3cd00336134a0710059c7ccff0..6be2efe6334ad8e43c917b77cecf1633dc0b2852 100644 (file)
 /* 5 - MIB Counters */
 #define REG_PORT_MIB_CTRL_STAT__4      0x0500
 
-#define MIB_COUNTER_OVERFLOW           BIT(31)
-#define MIB_COUNTER_VALID              BIT(30)
 #define MIB_COUNTER_READ               BIT(25)
 #define MIB_COUNTER_FLUSH_FREEZE       BIT(24)
 #define MIB_COUNTER_INDEX_M            (BIT(8) - 1)
index acaa0e96f5ffb9156901a0d33bc98f6949cd54f0..fc1ef0e50bff89ee3cfe0523f85bd5cf9ece4427 100644 (file)
@@ -218,6 +218,28 @@ static const u8 ksz8795_regs[] = {
        [S_TAIL_TAG_CTRL]               = 0x0C,
 };
 
+static const u32 ksz8795_masks[] = {
+       [PORT_802_1P_REMAPPING]         = BIT(7),
+       [SW_TAIL_TAG_ENABLE]            = BIT(1),
+       [MIB_COUNTER_OVERFLOW]          = BIT(6),
+       [MIB_COUNTER_VALID]             = BIT(5),
+       [VLAN_TABLE_FID]                = GENMASK(6, 0),
+       [VLAN_TABLE_MEMBERSHIP]         = GENMASK(11, 7),
+       [VLAN_TABLE_VALID]              = BIT(12),
+       [STATIC_MAC_TABLE_VALID]        = BIT(21),
+       [STATIC_MAC_TABLE_USE_FID]      = BIT(23),
+       [STATIC_MAC_TABLE_FID]          = GENMASK(30, 24),
+       [STATIC_MAC_TABLE_OVERRIDE]     = BIT(26),
+       [STATIC_MAC_TABLE_FWD_PORTS]    = GENMASK(24, 20),
+       [DYNAMIC_MAC_TABLE_ENTRIES_H]   = GENMASK(6, 0),
+       [DYNAMIC_MAC_TABLE_MAC_EMPTY]   = BIT(8),
+       [DYNAMIC_MAC_TABLE_NOT_READY]   = BIT(7),
+       [DYNAMIC_MAC_TABLE_ENTRIES]     = GENMASK(31, 29),
+       [DYNAMIC_MAC_TABLE_FID]         = GENMASK(26, 20),
+       [DYNAMIC_MAC_TABLE_SRC_PORT]    = GENMASK(26, 24),
+       [DYNAMIC_MAC_TABLE_TIMESTAMP]   = GENMASK(28, 27),
+};
+
 static const u8 ksz8863_regs[] = {
        [REG_IND_CTRL_0]                = 0x79,
        [REG_IND_DATA_8]                = 0x7B,
@@ -234,6 +256,28 @@ static const u8 ksz8863_regs[] = {
        [S_TAIL_TAG_CTRL]               = 0x03,
 };
 
+static const u32 ksz8863_masks[] = {
+       [PORT_802_1P_REMAPPING]         = BIT(3),
+       [SW_TAIL_TAG_ENABLE]            = BIT(6),
+       [MIB_COUNTER_OVERFLOW]          = BIT(7),
+       [MIB_COUNTER_VALID]             = BIT(6),
+       [VLAN_TABLE_FID]                = GENMASK(15, 12),
+       [VLAN_TABLE_MEMBERSHIP]         = GENMASK(18, 16),
+       [VLAN_TABLE_VALID]              = BIT(19),
+       [STATIC_MAC_TABLE_VALID]        = BIT(19),
+       [STATIC_MAC_TABLE_USE_FID]      = BIT(21),
+       [STATIC_MAC_TABLE_FID]          = GENMASK(29, 26),
+       [STATIC_MAC_TABLE_OVERRIDE]     = BIT(20),
+       [STATIC_MAC_TABLE_FWD_PORTS]    = GENMASK(18, 16),
+       [DYNAMIC_MAC_TABLE_ENTRIES_H]   = GENMASK(5, 0),
+       [DYNAMIC_MAC_TABLE_MAC_EMPTY]   = BIT(7),
+       [DYNAMIC_MAC_TABLE_NOT_READY]   = BIT(7),
+       [DYNAMIC_MAC_TABLE_ENTRIES]     = GENMASK(31, 28),
+       [DYNAMIC_MAC_TABLE_FID]         = GENMASK(19, 16),
+       [DYNAMIC_MAC_TABLE_SRC_PORT]    = GENMASK(21, 20),
+       [DYNAMIC_MAC_TABLE_TIMESTAMP]   = GENMASK(23, 22),
+};
+
 const struct ksz_chip_data ksz_switch_chips[] = {
        [KSZ8795] = {
                .chip_id = KSZ8795_CHIP_ID,
@@ -249,6 +293,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
                .regs = ksz8795_regs,
+               .masks = ksz8795_masks,
                .stp_ctrl_reg = 0x02,
                .broadcast_ctrl_reg =  0x06,
                .multicast_ctrl_reg = 0x04,
@@ -287,6 +332,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
                .regs = ksz8795_regs,
+               .masks = ksz8795_masks,
                .stp_ctrl_reg = 0x02,
                .broadcast_ctrl_reg =  0x06,
                .multicast_ctrl_reg = 0x04,
@@ -311,6 +357,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
                .regs = ksz8795_regs,
+               .masks = ksz8795_masks,
                .stp_ctrl_reg = 0x02,
                .broadcast_ctrl_reg =  0x06,
                .multicast_ctrl_reg = 0x04,
@@ -334,6 +381,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
                .mib_cnt = ARRAY_SIZE(ksz88xx_mib_names),
                .reg_mib_cnt = MIB_COUNTER_NUM,
                .regs = ksz8863_regs,
+               .masks = ksz8863_masks,
                .stp_ctrl_reg = 0x02,
                .broadcast_ctrl_reg =  0x06,
                .multicast_ctrl_reg = 0x04,
index d3cd29ef7885f8aaea0ed9fccdf4410287a8f3a7..b1e4732357a1fc8c3d7ecb9f25090a39b84bf382 100644 (file)
@@ -48,6 +48,7 @@ struct ksz_chip_data {
        int mib_cnt;
        u8 reg_mib_cnt;
        const u8 *regs;
+       const u32 *masks;
        int stp_ctrl_reg;
        int broadcast_ctrl_reg;
        int multicast_ctrl_reg;
@@ -164,6 +165,28 @@ enum ksz_regs {
        S_TAIL_TAG_CTRL,
 };
 
+enum ksz_masks {
+       PORT_802_1P_REMAPPING,
+       SW_TAIL_TAG_ENABLE,
+       MIB_COUNTER_OVERFLOW,
+       MIB_COUNTER_VALID,
+       VLAN_TABLE_FID,
+       VLAN_TABLE_MEMBERSHIP,
+       VLAN_TABLE_VALID,
+       STATIC_MAC_TABLE_VALID,
+       STATIC_MAC_TABLE_USE_FID,
+       STATIC_MAC_TABLE_FID,
+       STATIC_MAC_TABLE_OVERRIDE,
+       STATIC_MAC_TABLE_FWD_PORTS,
+       DYNAMIC_MAC_TABLE_ENTRIES_H,
+       DYNAMIC_MAC_TABLE_MAC_EMPTY,
+       DYNAMIC_MAC_TABLE_NOT_READY,
+       DYNAMIC_MAC_TABLE_ENTRIES,
+       DYNAMIC_MAC_TABLE_FID,
+       DYNAMIC_MAC_TABLE_SRC_PORT,
+       DYNAMIC_MAC_TABLE_TIMESTAMP,
+};
+
 struct alu_struct {
        /* entry 1 */
        u8      is_static:1;