From patchwork Tue Jun 28 17:13:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Ramadoss X-Patchwork-Id: 12898585 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56D5AC43334 for ; Tue, 28 Jun 2022 17:14:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232442AbiF1ROO (ORCPT ); Tue, 28 Jun 2022 13:14:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiF1ROL (ORCPT ); Tue, 28 Jun 2022 13:14:11 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2A2A2B196; Tue, 28 Jun 2022 10:14:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1656436450; x=1687972450; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NIPcuY+NNf8GaIfdmPmjmQBCBxQr8BX2SAgmu6yHNIE=; b=xRbGuvDqnB+OWDTd9lHBqlaiHpozBFyr2MYx31NnOoUjf2wuhE5/eRAM kC3OG+jq+KQ8cpgm7y+mpqvrJ1hroalIgmWQAGij46nNJftzNNufFWk83 dnM+4FRaCUS9hb9+7kcz+hfc+BGp6WuyLuINSTezNX3mS7Eb3WettkANW QB2/mWtOoK6HPkmYS0UDH/0iZ4a4MswPhrZEO//DKosJXnpumxIuU9eJY I4ld/RGaTWf/XEv28aci3oL3lLm7Kpg7ROIC+dj1Ib5JKVjqxueU/HuDv iGq6aLBayAwhIp4BF4saeOYv70bAc9XVskIe/DomVyRZx8FWLOlQKSSXf A==; X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="102137950" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Jun 2022 10:14:09 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 28 Jun 2022 10:14:09 -0700 Received: from CHE-LT-I17769U.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 28 Jun 2022 10:13:57 -0700 From: Arun Ramadoss To: , CC: Woojung Huh , , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King" Subject: [Patch net-next 1/7] net: dsa: microchip: move ksz8->regs to ksz_common Date: Tue, 28 Jun 2022 22:43:23 +0530 Message-ID: <20220628171329.25503-2-arun.ramadoss@microchip.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628171329.25503-1-arun.ramadoss@microchip.com> References: <20220628171329.25503-1-arun.ramadoss@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch moves the ksz8->regs from ksz8795.c to the ksz_common.c. And the regs is dereferrenced using dev->info->regs. Signed-off-by: Arun Ramadoss --- drivers/net/dsa/microchip/ksz8.h | 18 ------ drivers/net/dsa/microchip/ksz8795.c | 76 ++++++++----------------- drivers/net/dsa/microchip/ksz9477_reg.h | 3 - drivers/net/dsa/microchip/ksz_common.c | 37 ++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 18 ++++++ 5 files changed, 79 insertions(+), 73 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.h b/drivers/net/dsa/microchip/ksz8.h index de246989c81b..465b91496ea0 100644 --- a/drivers/net/dsa/microchip/ksz8.h +++ b/drivers/net/dsa/microchip/ksz8.h @@ -12,23 +12,6 @@ #include #include "ksz_common.h" -enum ksz_regs { - REG_IND_CTRL_0, - REG_IND_DATA_8, - REG_IND_DATA_CHECK, - REG_IND_DATA_HI, - REG_IND_DATA_LO, - REG_IND_MIB_CHECK, - REG_IND_BYTE, - P_FORCE_CTRL, - P_LINK_STATUS, - P_LOCAL_CTRL, - P_NEG_RESTART_CTRL, - P_REMOTE_STATUS, - P_SPEED_STATUS, - S_TAIL_TAG_CTRL, -}; - enum ksz_masks { PORT_802_1P_REMAPPING, SW_TAIL_TAG_ENABLE, @@ -64,7 +47,6 @@ enum ksz_shifts { }; struct ksz8 { - const u8 *regs; const u32 *masks; const u8 *shifts; void *priv; diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index df7d782e3fcd..deac3a40381e 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -26,23 +26,6 @@ #include "ksz8795_reg.h" #include "ksz8.h" -static const u8 ksz8795_regs[] = { - [REG_IND_CTRL_0] = 0x6E, - [REG_IND_DATA_8] = 0x70, - [REG_IND_DATA_CHECK] = 0x72, - [REG_IND_DATA_HI] = 0x71, - [REG_IND_DATA_LO] = 0x75, - [REG_IND_MIB_CHECK] = 0x74, - [REG_IND_BYTE] = 0xA0, - [P_FORCE_CTRL] = 0x0C, - [P_LINK_STATUS] = 0x0E, - [P_LOCAL_CTRL] = 0x07, - [P_NEG_RESTART_CTRL] = 0x0D, - [P_REMOTE_STATUS] = 0x08, - [P_SPEED_STATUS] = 0x09, - [S_TAIL_TAG_CTRL] = 0x0C, -}; - static const u32 ksz8795_masks[] = { [PORT_802_1P_REMAPPING] = BIT(7), [SW_TAIL_TAG_ENABLE] = BIT(1), @@ -77,22 +60,6 @@ static const u8 ksz8795_shifts[] = { [DYNAMIC_MAC_SRC_PORT] = 24, }; -static const u8 ksz8863_regs[] = { - [REG_IND_CTRL_0] = 0x79, - [REG_IND_DATA_8] = 0x7B, - [REG_IND_DATA_CHECK] = 0x7B, - [REG_IND_DATA_HI] = 0x7C, - [REG_IND_DATA_LO] = 0x80, - [REG_IND_MIB_CHECK] = 0x80, - [P_FORCE_CTRL] = 0x0C, - [P_LINK_STATUS] = 0x0E, - [P_LOCAL_CTRL] = 0x0C, - [P_NEG_RESTART_CTRL] = 0x0D, - [P_REMOTE_STATUS] = 0x0E, - [P_SPEED_STATUS] = 0x0F, - [S_TAIL_TAG_CTRL] = 0x03, -}; - static const u32 ksz8863_masks[] = { [PORT_802_1P_REMAPPING] = BIT(3), [SW_TAIL_TAG_ENABLE] = BIT(6), @@ -145,11 +112,12 @@ static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits, static int ksz8_ind_write8(struct ksz_device *dev, u8 table, u16 addr, u8 data) { - struct ksz8 *ksz8 = dev->priv; - const u8 *regs = ksz8->regs; + const u8 *regs; u16 ctrl_addr; int ret = 0; + regs = dev->info->regs; + mutex_lock(&dev->alu_mutex); ctrl_addr = IND_ACC_TABLE(table) | addr; @@ -224,7 +192,7 @@ void ksz8_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt) int loop; masks = ksz8->masks; - regs = ksz8->regs; + regs = dev->info->regs; ctrl_addr = addr + dev->info->reg_mib_cnt * port; ctrl_addr |= IND_ACC_TABLE(TABLE_MIB | TABLE_READ); @@ -261,7 +229,7 @@ static void ksz8795_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, int loop; masks = ksz8->masks; - regs = ksz8->regs; + regs = dev->info->regs; addr -= dev->info->reg_mib_cnt; ctrl_addr = (KSZ8795_MIB_TOTAL_RX_1 - KSZ8795_MIB_TOTAL_RX_0) * port; @@ -305,13 +273,14 @@ static void ksz8795_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, static void ksz8863_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, u64 *dropped, u64 *cnt) { - struct ksz8 *ksz8 = dev->priv; - const u8 *regs = ksz8->regs; u32 *last = (u32 *)dropped; + const u8 *regs; u16 ctrl_addr; u32 data; u32 cur; + regs = dev->info->regs; + addr -= dev->info->reg_mib_cnt; ctrl_addr = addr ? KSZ8863_MIB_PACKET_DROPPED_TX_0 : KSZ8863_MIB_PACKET_DROPPED_RX_0; @@ -392,10 +361,11 @@ void ksz8_port_init_cnt(struct ksz_device *dev, int port) static void ksz8_r_table(struct ksz_device *dev, int table, u16 addr, u64 *data) { - struct ksz8 *ksz8 = dev->priv; - const u8 *regs = ksz8->regs; + const u8 *regs; u16 ctrl_addr; + regs = dev->info->regs; + ctrl_addr = IND_ACC_TABLE(table | TABLE_READ) | addr; mutex_lock(&dev->alu_mutex); @@ -406,10 +376,11 @@ static void ksz8_r_table(struct ksz_device *dev, int table, u16 addr, u64 *data) static void ksz8_w_table(struct ksz_device *dev, int table, u16 addr, u64 data) { - struct ksz8 *ksz8 = dev->priv; - const u8 *regs = ksz8->regs; + const u8 *regs; u16 ctrl_addr; + regs = dev->info->regs; + ctrl_addr = IND_ACC_TABLE(table) | addr; mutex_lock(&dev->alu_mutex); @@ -426,7 +397,7 @@ static int ksz8_valid_dyn_entry(struct ksz_device *dev, u8 *data) const u8 *regs; masks = ksz8->masks; - regs = ksz8->regs; + regs = dev->info->regs; do { ksz_read8(dev, regs[REG_IND_DATA_CHECK], data); @@ -461,7 +432,7 @@ int ksz8_r_dyn_mac_table(struct ksz_device *dev, u16 addr, u8 *mac_addr, shifts = ksz8->shifts; masks = ksz8->masks; - regs = ksz8->regs; + regs = dev->info->regs; ctrl_addr = IND_ACC_TABLE(TABLE_DYNAMIC_MAC | TABLE_READ) | addr; @@ -664,14 +635,15 @@ static void ksz8_w_vlan_table(struct ksz_device *dev, u16 vid, u16 vlan) void ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val) { - struct ksz8 *ksz8 = dev->priv; u8 restart, speed, ctrl, link; - const u8 *regs = ksz8->regs; int processed = true; + const u8 *regs; u8 val1, val2; u16 data = 0; u8 p = phy; + regs = dev->info->regs; + switch (reg) { case MII_BMCR: ksz_pread8(dev, p, regs[P_NEG_RESTART_CTRL], &restart); @@ -787,11 +759,12 @@ void ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val) void ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val) { - struct ksz8 *ksz8 = dev->priv; u8 restart, speed, ctrl, data; - const u8 *regs = ksz8->regs; + const u8 *regs; u8 p = phy; + regs = dev->info->regs; + switch (reg) { case MII_BMCR: @@ -1302,13 +1275,14 @@ void ksz8_config_cpu_port(struct dsa_switch *ds) { struct ksz_device *dev = ds->priv; struct ksz8 *ksz8 = dev->priv; - const u8 *regs = ksz8->regs; struct ksz_port *p; const u32 *masks; + const u8 *regs; u8 remote; int i; masks = ksz8->masks; + regs = dev->info->regs; /* Switch marks the maximum frame with extra byte as oversize. */ ksz_cfg(dev, REG_SW_CTRL_2, SW_LEGAL_PACKET_DISABLE, true); @@ -1448,11 +1422,9 @@ 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->regs = ksz8863_regs; ksz8->masks = ksz8863_masks; ksz8->shifts = ksz8863_shifts; } else { - ksz8->regs = ksz8795_regs; ksz8->masks = ksz8795_masks; ksz8->shifts = ksz8795_shifts; } diff --git a/drivers/net/dsa/microchip/ksz9477_reg.h b/drivers/net/dsa/microchip/ksz9477_reg.h index c0ad83753b13..2cbbfda22c67 100644 --- a/drivers/net/dsa/microchip/ksz9477_reg.h +++ b/drivers/net/dsa/microchip/ksz9477_reg.h @@ -1624,9 +1624,6 @@ #define P_MIRROR_CTRL REG_PORT_MRI_MIRROR_CTRL #define P_STP_CTRL REG_PORT_LUE_MSTP_STATE #define P_PHY_CTRL REG_PORT_PHY_CTRL -#define P_NEG_RESTART_CTRL REG_PORT_PHY_CTRL -#define P_LINK_STATUS REG_PORT_PHY_STATUS -#define P_SPEED_STATUS REG_PORT_PHY_PHY_CTRL #define P_RATE_LIMIT_CTRL REG_PORT_MAC_IN_RATE_LIMIT #define S_LINK_AGING_CTRL REG_SW_LUE_CTRL_1 diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 59582eb3bcaf..acaa0e96f5ff 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -201,6 +201,39 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .exit = ksz9477_switch_exit, }; +static const u8 ksz8795_regs[] = { + [REG_IND_CTRL_0] = 0x6E, + [REG_IND_DATA_8] = 0x70, + [REG_IND_DATA_CHECK] = 0x72, + [REG_IND_DATA_HI] = 0x71, + [REG_IND_DATA_LO] = 0x75, + [REG_IND_MIB_CHECK] = 0x74, + [REG_IND_BYTE] = 0xA0, + [P_FORCE_CTRL] = 0x0C, + [P_LINK_STATUS] = 0x0E, + [P_LOCAL_CTRL] = 0x07, + [P_NEG_RESTART_CTRL] = 0x0D, + [P_REMOTE_STATUS] = 0x08, + [P_SPEED_STATUS] = 0x09, + [S_TAIL_TAG_CTRL] = 0x0C, +}; + +static const u8 ksz8863_regs[] = { + [REG_IND_CTRL_0] = 0x79, + [REG_IND_DATA_8] = 0x7B, + [REG_IND_DATA_CHECK] = 0x7B, + [REG_IND_DATA_HI] = 0x7C, + [REG_IND_DATA_LO] = 0x80, + [REG_IND_MIB_CHECK] = 0x80, + [P_FORCE_CTRL] = 0x0C, + [P_LINK_STATUS] = 0x0E, + [P_LOCAL_CTRL] = 0x0C, + [P_NEG_RESTART_CTRL] = 0x0D, + [P_REMOTE_STATUS] = 0x0E, + [P_SPEED_STATUS] = 0x0F, + [S_TAIL_TAG_CTRL] = 0x03, +}; + const struct ksz_chip_data ksz_switch_chips[] = { [KSZ8795] = { .chip_id = KSZ8795_CHIP_ID, @@ -215,6 +248,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, + .regs = ksz8795_regs, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, @@ -252,6 +286,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, + .regs = ksz8795_regs, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, @@ -275,6 +310,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, + .regs = ksz8795_regs, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, @@ -297,6 +333,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz88xx_mib_names, .mib_cnt = ARRAY_SIZE(ksz88xx_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, + .regs = ksz8863_regs, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 0e7f15efbb79..d3cd29ef7885 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -47,6 +47,7 @@ struct ksz_chip_data { const struct ksz_mib_names *mib_names; int mib_cnt; u8 reg_mib_cnt; + const u8 *regs; int stp_ctrl_reg; int broadcast_ctrl_reg; int multicast_ctrl_reg; @@ -146,6 +147,23 @@ enum ksz_chip_id { LAN9374_CHIP_ID = 0x00937400, }; +enum ksz_regs { + REG_IND_CTRL_0, + REG_IND_DATA_8, + REG_IND_DATA_CHECK, + REG_IND_DATA_HI, + REG_IND_DATA_LO, + REG_IND_MIB_CHECK, + REG_IND_BYTE, + P_FORCE_CTRL, + P_LINK_STATUS, + P_LOCAL_CTRL, + P_NEG_RESTART_CTRL, + P_REMOTE_STATUS, + P_SPEED_STATUS, + S_TAIL_TAG_CTRL, +}; + struct alu_struct { /* entry 1 */ u8 is_static:1; From patchwork Tue Jun 28 17:13:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Ramadoss X-Patchwork-Id: 12898586 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFDFBC43334 for ; Tue, 28 Jun 2022 17:14:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232538AbiF1ROa (ORCPT ); Tue, 28 Jun 2022 13:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230296AbiF1ROa (ORCPT ); Tue, 28 Jun 2022 13:14:30 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD61E2B196; Tue, 28 Jun 2022 10:14:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1656436468; x=1687972468; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6lVXwkW1jzzRilI6/9b+EBfwv5lxJ8J+J0kSzXW729w=; b=XTXyMYeY50PGrOaj4EGNgJZzH04XVYc6ofvYmAGBLHsLODlJvNQ6hii/ l1+ugIWkW55bq942kZPPUB/1+IAknL7UIg9F8JTvAnsIhHc/oSIcC3ydN /Th+zvGeVQdCeQc0WRy554I0D08MPOIteh954yRauNC9Fg1omktxD6scM j80fgnglOk4Jy2af8ucX1ts7x2cfX1xyrO2elbcSxY4fAfmsS0aeZukbz R1lap7zqOkvj8FZqOtuOBq9AGfFRWW/r5L1T8LgmzRb0POgHEqWrlaaBv 39eCYOyrfU+2YHkunSaKfjBmTgOHvbEDNUanK5fzuif++2fQvUdCvMVYf w==; X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="179885868" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Jun 2022 10:14:26 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 28 Jun 2022 10:14:22 -0700 Received: from CHE-LT-I17769U.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 28 Jun 2022 10:14:12 -0700 From: Arun Ramadoss To: , CC: Woojung Huh , , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King" Subject: [Patch net-next 2/7] net: dsa: microchip: move ksz8->masks to ksz_common Date: Tue, 28 Jun 2022 22:43:24 +0530 Message-ID: <20220628171329.25503-3-arun.ramadoss@microchip.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628171329.25503-1-arun.ramadoss@microchip.com> References: <20220628171329.25503-1-arun.ramadoss@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 --- drivers/net/dsa/microchip/ksz8.h | 23 -------- drivers/net/dsa/microchip/ksz8795.c | 71 ++++--------------------- drivers/net/dsa/microchip/ksz9477_reg.h | 2 - drivers/net/dsa/microchip/ksz_common.c | 48 +++++++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 23 ++++++++ 5 files changed, 81 insertions(+), 86 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.h b/drivers/net/dsa/microchip/ksz8.h index 465b91496ea0..22a047761aa5 100644 --- a/drivers/net/dsa/microchip/ksz8.h +++ b/drivers/net/dsa/microchip/ksz8.h @@ -12,28 +12,6 @@ #include #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; }; diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index deac3a40381e..0c72ec50c04d 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -26,28 +26,6 @@ #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; } diff --git a/drivers/net/dsa/microchip/ksz9477_reg.h b/drivers/net/dsa/microchip/ksz9477_reg.h index 2cbbfda22c67..6be2efe6334a 100644 --- a/drivers/net/dsa/microchip/ksz9477_reg.h +++ b/drivers/net/dsa/microchip/ksz9477_reg.h @@ -1262,8 +1262,6 @@ /* 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) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index acaa0e96f5ff..fc1ef0e50bff 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -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, diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index d3cd29ef7885..b1e4732357a1 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -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; From patchwork Tue Jun 28 17:13:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Ramadoss X-Patchwork-Id: 12898587 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C34A9C43334 for ; Tue, 28 Jun 2022 17:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232602AbiF1ROr (ORCPT ); Tue, 28 Jun 2022 13:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230296AbiF1ROk (ORCPT ); Tue, 28 Jun 2022 13:14:40 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E94B52CCA0; Tue, 28 Jun 2022 10:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1656436480; x=1687972480; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4aUB8XdEZI44hkwWiLzjnR4eIChSP8Np2Da2KuqwoQs=; b=xDcJ9HlJSG4KI9L0bJJnBpWiFTp+4EyBmNYVSrwGmPmI68pd08MMpK92 NhrjL/ojAzAjyYO8xiIFlWyvjf4cY0kRnotk1yIzOgRjr+r5OTFfs8Wac SEKSdFGQfeTMoqHBqf6m5a/qu35Ny1nnnFlsKfUb+sZeW1kbDobtx8Ocs SSNf0cgcCCRb7TUo4ESBmkjdVCLGppJ+/7Ed/rMB2jLwp5ngnhQFIOOo6 1W/OQnq1lYQn3GShwq94+//XH4WeqDP0t5DN4U6QsBg/7COFDUOFJ+dxB q7kDI782TZV9W5MR8xQN0FT4Q4w2MSwW15VbhnGBlzsGomffeHNwavSzn A==; X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="169967896" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Jun 2022 10:14:40 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 28 Jun 2022 10:14:36 -0700 Received: from CHE-LT-I17769U.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 28 Jun 2022 10:14:25 -0700 From: Arun Ramadoss To: , CC: Woojung Huh , , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King" Subject: [Patch net-next 3/7] net: dsa: microchip: move ksz8->shifts to ksz_common Date: Tue, 28 Jun 2022 22:43:25 +0530 Message-ID: <20220628171329.25503-4-arun.ramadoss@microchip.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628171329.25503-1-arun.ramadoss@microchip.com> References: <20220628171329.25503-1-arun.ramadoss@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch moves ksz8->shifts from ksz8795.c to ksz_common.c. The shifts are dereferenced using dev->info->shifts. Signed-off-by: Arun Ramadoss --- drivers/net/dsa/microchip/ksz8.h | 13 ------- drivers/net/dsa/microchip/ksz8795.c | 49 ++++---------------------- drivers/net/dsa/microchip/ksz_common.c | 27 ++++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 13 +++++++ 4 files changed, 46 insertions(+), 56 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.h b/drivers/net/dsa/microchip/ksz8.h index 22a047761aa5..a4a2dc889b30 100644 --- a/drivers/net/dsa/microchip/ksz8.h +++ b/drivers/net/dsa/microchip/ksz8.h @@ -12,20 +12,7 @@ #include #include "ksz_common.h" -enum ksz_shifts { - VLAN_TABLE_MEMBERSHIP_S, - VLAN_TABLE, - STATIC_MAC_FWD_PORTS, - STATIC_MAC_FID, - DYNAMIC_MAC_ENTRIES_H, - DYNAMIC_MAC_ENTRIES, - DYNAMIC_MAC_FID, - DYNAMIC_MAC_TIMESTAMP, - DYNAMIC_MAC_SRC_PORT, -}; - struct ksz8 { - const u8 *shifts; void *priv; }; diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 0c72ec50c04d..2b3db33c32ce 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -26,29 +26,6 @@ #include "ksz8795_reg.h" #include "ksz8.h" -static const u8 ksz8795_shifts[] = { - [VLAN_TABLE_MEMBERSHIP_S] = 7, - [VLAN_TABLE] = 16, - [STATIC_MAC_FWD_PORTS] = 16, - [STATIC_MAC_FID] = 24, - [DYNAMIC_MAC_ENTRIES_H] = 3, - [DYNAMIC_MAC_ENTRIES] = 29, - [DYNAMIC_MAC_FID] = 16, - [DYNAMIC_MAC_TIMESTAMP] = 27, - [DYNAMIC_MAC_SRC_PORT] = 24, -}; - -static u8 ksz8863_shifts[] = { - [VLAN_TABLE_MEMBERSHIP_S] = 16, - [STATIC_MAC_FWD_PORTS] = 16, - [STATIC_MAC_FID] = 22, - [DYNAMIC_MAC_ENTRIES_H] = 3, - [DYNAMIC_MAC_ENTRIES] = 24, - [DYNAMIC_MAC_FID] = 16, - [DYNAMIC_MAC_TIMESTAMP] = 24, - [DYNAMIC_MAC_SRC_PORT] = 20, -}; - static bool ksz_is_ksz88x3(struct ksz_device *dev) { return dev->chip_id == 0x8830; @@ -374,7 +351,6 @@ static int ksz8_valid_dyn_entry(struct ksz_device *dev, u8 *data) int ksz8_r_dyn_mac_table(struct ksz_device *dev, u16 addr, u8 *mac_addr, u8 *fid, u8 *src_port, u8 *timestamp, u16 *entries) { - struct ksz8 *ksz8 = dev->priv; u32 data_hi, data_lo; const u8 *shifts; const u32 *masks; @@ -383,7 +359,7 @@ int ksz8_r_dyn_mac_table(struct ksz_device *dev, u16 addr, u8 *mac_addr, u8 data; int rc; - shifts = ksz8->shifts; + shifts = dev->info->shifts; masks = dev->info->masks; regs = dev->info->regs; @@ -438,13 +414,12 @@ int ksz8_r_dyn_mac_table(struct ksz_device *dev, u16 addr, u8 *mac_addr, int ksz8_r_sta_mac_table(struct ksz_device *dev, u16 addr, struct alu_struct *alu) { - struct ksz8 *ksz8 = dev->priv; u32 data_hi, data_lo; const u8 *shifts; const u32 *masks; u64 data; - shifts = ksz8->shifts; + shifts = dev->info->shifts; masks = dev->info->masks; ksz8_r_table(dev, TABLE_STATIC_MAC, addr, &data); @@ -477,13 +452,12 @@ int ksz8_r_sta_mac_table(struct ksz_device *dev, u16 addr, void ksz8_w_sta_mac_table(struct ksz_device *dev, u16 addr, struct alu_struct *alu) { - struct ksz8 *ksz8 = dev->priv; u32 data_hi, data_lo; const u8 *shifts; const u32 *masks; u64 data; - shifts = ksz8->shifts; + shifts = dev->info->shifts; masks = dev->info->masks; data_lo = ((u32)alu->mac[2] << 24) | @@ -510,11 +484,10 @@ void ksz8_w_sta_mac_table(struct ksz_device *dev, u16 addr, static void ksz8_from_vlan(struct ksz_device *dev, u32 vlan, u8 *fid, u8 *member, u8 *valid) { - struct ksz8 *ksz8 = dev->priv; const u8 *shifts; const u32 *masks; - shifts = ksz8->shifts; + shifts = dev->info->shifts; masks = dev->info->masks; *fid = vlan & masks[VLAN_TABLE_FID]; @@ -526,11 +499,10 @@ static void ksz8_from_vlan(struct ksz_device *dev, u32 vlan, u8 *fid, static void ksz8_to_vlan(struct ksz_device *dev, u8 fid, u8 member, u8 valid, u16 *vlan) { - struct ksz8 *ksz8 = dev->priv; const u8 *shifts; const u32 *masks; - shifts = ksz8->shifts; + shifts = dev->info->shifts; masks = dev->info->masks; *vlan = fid; @@ -541,12 +513,11 @@ static void ksz8_to_vlan(struct ksz_device *dev, u8 fid, u8 member, u8 valid, static void ksz8_r_vlan_entries(struct ksz_device *dev, u16 addr) { - struct ksz8 *ksz8 = dev->priv; const u8 *shifts; u64 data; int i; - shifts = ksz8->shifts; + shifts = dev->info->shifts; ksz8_r_table(dev, TABLE_VLAN, addr, &data); addr *= 4; @@ -1366,18 +1337,10 @@ u32 ksz8_get_port_addr(int port, int offset) int ksz8_switch_init(struct ksz_device *dev) { - struct ksz8 *ksz8 = dev->priv; - dev->cpu_port = fls(dev->info->cpu_ports) - 1; dev->phy_port_cnt = dev->info->port_cnt - 1; dev->port_mask = (BIT(dev->phy_port_cnt) - 1) | dev->info->cpu_ports; - if (ksz_is_ksz88x3(dev)) { - ksz8->shifts = ksz8863_shifts; - } else { - ksz8->shifts = ksz8795_shifts; - } - /* We rely on software untagging on the CPU port, so that we * can support both tagged and untagged VLANs */ diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index fc1ef0e50bff..fa66bd14f66a 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -240,6 +240,18 @@ static const u32 ksz8795_masks[] = { [DYNAMIC_MAC_TABLE_TIMESTAMP] = GENMASK(28, 27), }; +static const u8 ksz8795_shifts[] = { + [VLAN_TABLE_MEMBERSHIP_S] = 7, + [VLAN_TABLE] = 16, + [STATIC_MAC_FWD_PORTS] = 16, + [STATIC_MAC_FID] = 24, + [DYNAMIC_MAC_ENTRIES_H] = 3, + [DYNAMIC_MAC_ENTRIES] = 29, + [DYNAMIC_MAC_FID] = 16, + [DYNAMIC_MAC_TIMESTAMP] = 27, + [DYNAMIC_MAC_SRC_PORT] = 24, +}; + static const u8 ksz8863_regs[] = { [REG_IND_CTRL_0] = 0x79, [REG_IND_DATA_8] = 0x7B, @@ -278,6 +290,17 @@ static const u32 ksz8863_masks[] = { [DYNAMIC_MAC_TABLE_TIMESTAMP] = GENMASK(23, 22), }; +static u8 ksz8863_shifts[] = { + [VLAN_TABLE_MEMBERSHIP_S] = 16, + [STATIC_MAC_FWD_PORTS] = 16, + [STATIC_MAC_FID] = 22, + [DYNAMIC_MAC_ENTRIES_H] = 3, + [DYNAMIC_MAC_ENTRIES] = 24, + [DYNAMIC_MAC_FID] = 16, + [DYNAMIC_MAC_TIMESTAMP] = 24, + [DYNAMIC_MAC_SRC_PORT] = 20, +}; + const struct ksz_chip_data ksz_switch_chips[] = { [KSZ8795] = { .chip_id = KSZ8795_CHIP_ID, @@ -294,6 +317,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz8795_regs, .masks = ksz8795_masks, + .shifts = ksz8795_shifts, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, @@ -333,6 +357,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz8795_regs, .masks = ksz8795_masks, + .shifts = ksz8795_shifts, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, @@ -358,6 +383,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz8795_regs, .masks = ksz8795_masks, + .shifts = ksz8795_shifts, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, @@ -382,6 +408,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz8863_regs, .masks = ksz8863_masks, + .shifts = ksz8863_shifts, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index b1e4732357a1..c11adf67757d 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -49,6 +49,7 @@ struct ksz_chip_data { u8 reg_mib_cnt; const u8 *regs; const u32 *masks; + const u8 *shifts; int stp_ctrl_reg; int broadcast_ctrl_reg; int multicast_ctrl_reg; @@ -187,6 +188,18 @@ enum ksz_masks { DYNAMIC_MAC_TABLE_TIMESTAMP, }; +enum ksz_shifts { + VLAN_TABLE_MEMBERSHIP_S, + VLAN_TABLE, + STATIC_MAC_FWD_PORTS, + STATIC_MAC_FID, + DYNAMIC_MAC_ENTRIES_H, + DYNAMIC_MAC_ENTRIES, + DYNAMIC_MAC_FID, + DYNAMIC_MAC_TIMESTAMP, + DYNAMIC_MAC_SRC_PORT, +}; + struct alu_struct { /* entry 1 */ u8 is_static:1; From patchwork Tue Jun 28 17:13:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Ramadoss X-Patchwork-Id: 12898588 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FD5AC43334 for ; Tue, 28 Jun 2022 17:15:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230393AbiF1RO7 (ORCPT ); Tue, 28 Jun 2022 13:14:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232609AbiF1RO4 (ORCPT ); Tue, 28 Jun 2022 13:14:56 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B06F2CCBD; Tue, 28 Jun 2022 10:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1656436493; x=1687972493; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wVM6MHqJ/3CzokUzpdzu9UEnvRuwP6DusvD+3MpK4b8=; b=E4r8dRUEw/gMPDYQFoN2ZSbTH252rgaDBnCgc6r3znB9p1sjO3dgg3bn 4YSwvepjggWsLYJMmyyGkos4w7/HEt05sYo6+x0/YmIbyyoJQJdkvnIsx L3M//LJc7X3eakb3zelxcul1gn3ZuxYqJt3TSLS7wkm6SirJfaU6X/ii4 Zwtqa68Vbuh7o3284en2V/YZTbbadK2xMzPfXoCTuM7YYRL7Lv23H4f1X P7AAbzJsCYKdLxUdE1Igj6LQMS0hTX1/wJV572Hu2aeVUgoTNyYf+bWDu z3ulfSQwqa0fhcGKE4VVFn+2yo5takAWXRb0GD4wtVayZ5su9oWgi2kwL g==; X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="102138314" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Jun 2022 10:14:52 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 28 Jun 2022 10:14:49 -0700 Received: from CHE-LT-I17769U.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 28 Jun 2022 10:14:38 -0700 From: Arun Ramadoss To: , CC: Woojung Huh , , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King" Subject: [Patch net-next 4/7] net: dsa: microchip: remove the struct ksz8 Date: Tue, 28 Jun 2022 22:43:26 +0530 Message-ID: <20220628171329.25503-5-arun.ramadoss@microchip.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628171329.25503-1-arun.ramadoss@microchip.com> References: <20220628171329.25503-1-arun.ramadoss@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch removes the struct ksz8 from ksz8.h which is no longer needed. The platform bus specific details are now deferenced through dev->priv. Signed-off-by: Arun Ramadoss --- drivers/net/dsa/microchip/ksz8.h | 4 ---- drivers/net/dsa/microchip/ksz8863_smi.c | 17 +++-------------- drivers/net/dsa/microchip/ksz_spi.c | 10 +--------- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.h b/drivers/net/dsa/microchip/ksz8.h index a4a2dc889b30..42c50cc4d853 100644 --- a/drivers/net/dsa/microchip/ksz8.h +++ b/drivers/net/dsa/microchip/ksz8.h @@ -12,10 +12,6 @@ #include #include "ksz_common.h" -struct ksz8 { - void *priv; -}; - int ksz8_setup(struct dsa_switch *ds); u32 ksz8_get_port_addr(int port, int offset); void ksz8_cfg_port_member(struct ksz_device *dev, int port, u8 member); diff --git a/drivers/net/dsa/microchip/ksz8863_smi.c b/drivers/net/dsa/microchip/ksz8863_smi.c index d71df05b8b7b..5247fdfb964d 100644 --- a/drivers/net/dsa/microchip/ksz8863_smi.c +++ b/drivers/net/dsa/microchip/ksz8863_smi.c @@ -26,11 +26,9 @@ static int ksz8863_mdio_read(void *ctx, const void *reg_buf, size_t reg_len, struct mdio_device *mdev; u8 reg = *(u8 *)reg_buf; u8 *val = val_buf; - struct ksz8 *ksz8; int i, ret = 0; - ksz8 = dev->priv; - mdev = ksz8->priv; + mdev = dev->priv; mutex_lock_nested(&mdev->bus->mdio_lock, MDIO_MUTEX_NESTED); for (i = 0; i < val_len; i++) { @@ -55,13 +53,11 @@ static int ksz8863_mdio_write(void *ctx, const void *data, size_t count) { struct ksz_device *dev = ctx; struct mdio_device *mdev; - struct ksz8 *ksz8; int i, ret = 0; u32 reg; u8 *val; - ksz8 = dev->priv; - mdev = ksz8->priv; + mdev = dev->priv; val = (u8 *)(data + 4); reg = *(u32 *)data; @@ -142,17 +138,10 @@ static int ksz8863_smi_probe(struct mdio_device *mdiodev) { struct regmap_config rc; struct ksz_device *dev; - struct ksz8 *ksz8; int ret; int i; - ksz8 = devm_kzalloc(&mdiodev->dev, sizeof(struct ksz8), GFP_KERNEL); - if (!ksz8) - return -ENOMEM; - - ksz8->priv = mdiodev; - - dev = ksz_switch_alloc(&mdiodev->dev, ksz8); + dev = ksz_switch_alloc(&mdiodev->dev, mdiodev); if (!dev) return -ENOMEM; diff --git a/drivers/net/dsa/microchip/ksz_spi.c b/drivers/net/dsa/microchip/ksz_spi.c index 344ff92db099..69fabb190f26 100644 --- a/drivers/net/dsa/microchip/ksz_spi.c +++ b/drivers/net/dsa/microchip/ksz_spi.c @@ -14,7 +14,6 @@ #include #include -#include "ksz8.h" #include "ksz_common.h" #define KSZ8795_SPI_ADDR_SHIFT 12 @@ -45,16 +44,9 @@ static int ksz_spi_probe(struct spi_device *spi) struct device *ddev = &spi->dev; struct regmap_config rc; struct ksz_device *dev; - struct ksz8 *ksz8; int i, ret = 0; - ksz8 = devm_kzalloc(&spi->dev, sizeof(struct ksz8), GFP_KERNEL); - if (!ksz8) - return -ENOMEM; - - ksz8->priv = spi; - - dev = ksz_switch_alloc(&spi->dev, ksz8); + dev = ksz_switch_alloc(&spi->dev, spi); if (!dev) return -ENOMEM; From patchwork Tue Jun 28 17:13:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Ramadoss X-Patchwork-Id: 12898589 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E522EC433EF for ; Tue, 28 Jun 2022 17:15:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232609AbiF1RPN (ORCPT ); Tue, 28 Jun 2022 13:15:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232642AbiF1RPL (ORCPT ); Tue, 28 Jun 2022 13:15:11 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 158422CDCC; Tue, 28 Jun 2022 10:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1656436506; x=1687972506; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jYglTYx+V76PBeSF7A9l6QurvfJiN1mDanoG8IpvadQ=; b=DXR9d3b4/L58u9FUGQYe9Du33fFP0ThJDKp4hhVkh0deMhZgBPsJZLVq d6OUgxQuUil9f6ULw+N5WR3CSVmH8gHqSqo6oDLDbyaDev9LT+BIjnNXC g5FlQCIZJHLtSV0+QsdWnExwHoQ5HaLf8wS0u5Mg9mAqCbepmLstFUYp1 nYB9qxuFnuVJJHBGDA5cqIanCaQd+DFK9EUrIq7sn35oZAMlX20+joGak ijR+zJgsgeuVErsuG1N5yhosswMRAbRaWEI0Z4dQUvouh3oBXc0v0xTZR 3mmLpH5/zNN5IIz7AhsyQyLmZalEWhToywG63sUkkCpDhsLLtIskey5yt w==; X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="162447853" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Jun 2022 10:15:05 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 28 Jun 2022 10:15:03 -0700 Received: from CHE-LT-I17769U.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 28 Jun 2022 10:14:51 -0700 From: Arun Ramadoss To: , CC: Woojung Huh , , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King" Subject: [Patch net-next 5/7] net: dsa: microchip: change the size of reg from u8 to u16 Date: Tue, 28 Jun 2022 22:43:27 +0530 Message-ID: <20220628171329.25503-6-arun.ramadoss@microchip.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628171329.25503-1-arun.ramadoss@microchip.com> References: <20220628171329.25503-1-arun.ramadoss@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The register size for the ksz8 switches is u8 and for ksz9477 series is u16. To have common struct for ksz series switches the size of reg is increased from u8 to u16. Signed-off-by: Arun Ramadoss --- drivers/net/dsa/microchip/ksz8795.c | 22 +++++++++++----------- drivers/net/dsa/microchip/ksz_common.c | 4 ++-- drivers/net/dsa/microchip/ksz_common.h | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 2b3db33c32ce..264c960f715d 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -45,7 +45,7 @@ static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits, static int ksz8_ind_write8(struct ksz_device *dev, u8 table, u16 addr, u8 data) { - const u8 *regs; + const u16 *regs; u16 ctrl_addr; int ret = 0; @@ -117,7 +117,7 @@ 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) { const u32 *masks; - const u8 *regs; + const u16 *regs; u16 ctrl_addr; u32 data; u8 check; @@ -153,7 +153,7 @@ static void ksz8795_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, u64 *dropped, u64 *cnt) { const u32 *masks; - const u8 *regs; + const u16 *regs; u16 ctrl_addr; u32 data; u8 check; @@ -205,7 +205,7 @@ static void ksz8863_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, u64 *dropped, u64 *cnt) { u32 *last = (u32 *)dropped; - const u8 *regs; + const u16 *regs; u16 ctrl_addr; u32 data; u32 cur; @@ -292,7 +292,7 @@ void ksz8_port_init_cnt(struct ksz_device *dev, int port) static void ksz8_r_table(struct ksz_device *dev, int table, u16 addr, u64 *data) { - const u8 *regs; + const u16 *regs; u16 ctrl_addr; regs = dev->info->regs; @@ -307,7 +307,7 @@ static void ksz8_r_table(struct ksz_device *dev, int table, u16 addr, u64 *data) static void ksz8_w_table(struct ksz_device *dev, int table, u16 addr, u64 data) { - const u8 *regs; + const u16 *regs; u16 ctrl_addr; regs = dev->info->regs; @@ -324,7 +324,7 @@ static int ksz8_valid_dyn_entry(struct ksz_device *dev, u8 *data) { int timeout = 100; const u32 *masks; - const u8 *regs; + const u16 *regs; masks = dev->info->masks; regs = dev->info->regs; @@ -354,7 +354,7 @@ int ksz8_r_dyn_mac_table(struct ksz_device *dev, u16 addr, u8 *mac_addr, u32 data_hi, data_lo; const u8 *shifts; const u32 *masks; - const u8 *regs; + const u16 *regs; u16 ctrl_addr; u8 data; int rc; @@ -561,7 +561,7 @@ void ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val) { u8 restart, speed, ctrl, link; int processed = true; - const u8 *regs; + const u16 *regs; u8 val1, val2; u16 data = 0; u8 p = phy; @@ -684,7 +684,7 @@ void ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val) void ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val) { u8 restart, speed, ctrl, data; - const u8 *regs; + const u16 *regs; u8 p = phy; regs = dev->info->regs; @@ -1199,7 +1199,7 @@ void ksz8_config_cpu_port(struct dsa_switch *ds) struct ksz_device *dev = ds->priv; struct ksz_port *p; const u32 *masks; - const u8 *regs; + const u16 *regs; u8 remote; int i; diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index fa66bd14f66a..4992fea208b1 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -201,7 +201,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .exit = ksz9477_switch_exit, }; -static const u8 ksz8795_regs[] = { +static const u16 ksz8795_regs[] = { [REG_IND_CTRL_0] = 0x6E, [REG_IND_DATA_8] = 0x70, [REG_IND_DATA_CHECK] = 0x72, @@ -252,7 +252,7 @@ static const u8 ksz8795_shifts[] = { [DYNAMIC_MAC_SRC_PORT] = 24, }; -static const u8 ksz8863_regs[] = { +static const u16 ksz8863_regs[] = { [REG_IND_CTRL_0] = 0x79, [REG_IND_DATA_8] = 0x7B, [REG_IND_DATA_CHECK] = 0x7B, diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index c11adf67757d..18794f571687 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -47,7 +47,7 @@ struct ksz_chip_data { const struct ksz_mib_names *mib_names; int mib_cnt; u8 reg_mib_cnt; - const u8 *regs; + const u16 *regs; const u32 *masks; const u8 *shifts; int stp_ctrl_reg; From patchwork Tue Jun 28 17:13:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Ramadoss X-Patchwork-Id: 12898590 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D612EC43334 for ; Tue, 28 Jun 2022 17:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232680AbiF1RPX (ORCPT ); Tue, 28 Jun 2022 13:15:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231248AbiF1RPW (ORCPT ); Tue, 28 Jun 2022 13:15:22 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B70172CE16; Tue, 28 Jun 2022 10:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1656436520; x=1687972520; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zF/2u1RfKmVqsubVwQwTjOVkYmvzUnki8PVBdFwZHuQ=; b=xvdrsmGz6nxIThh7h5HYN97LU0/j6+m7qaApw1cwQN5F4728j7SVELia PgvefR+orbIb+l6lYe/NcwkH1xq4S9jR3CVdvlR+JMH3cDN8cE4T/wQq/ a7lDqh47PYzEFUnazH1Mz6CWl5jPjC7aRSciMdnPhas5oEdNZ8Te2Abo1 Wc+i0v1ozVbjzDY2WqwZTeSARRrLgJJbvRLyzY+foRYc2sdEdgG6Oswzf XvwcycRD7k5imTpbWpAxkFtEnEzzWGnsiETYINSpeTl5LeBncYivHR3+v syHzKqbPyJveaqvC5SMeCsXX33OSN03VOT25IDOnsyuZ2E0qQuaUz+NG7 Q==; X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="102138586" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Jun 2022 10:15:19 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 28 Jun 2022 10:15:17 -0700 Received: from CHE-LT-I17769U.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 28 Jun 2022 10:15:06 -0700 From: Arun Ramadoss To: , CC: Woojung Huh , , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King" Subject: [Patch net-next 6/7] net: dsa: microchip: add P_STP_CTRL to ksz_chip_reg Date: Tue, 28 Jun 2022 22:43:28 +0530 Message-ID: <20220628171329.25503-7-arun.ramadoss@microchip.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628171329.25503-1-arun.ramadoss@microchip.com> References: <20220628171329.25503-1-arun.ramadoss@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch moves the stp_ctrl_reg from the ksz_chip_data to ksz_chip_reg structure. Signed-off-by: Arun Ramadoss --- drivers/net/dsa/microchip/ksz8795.c | 17 +++++++----- drivers/net/dsa/microchip/ksz8795_reg.h | 1 - drivers/net/dsa/microchip/ksz9477.c | 7 +++-- drivers/net/dsa/microchip/ksz9477_reg.h | 1 - drivers/net/dsa/microchip/ksz_common.c | 37 +++++++++++++------------ drivers/net/dsa/microchip/ksz_common.h | 1 + 6 files changed, 35 insertions(+), 29 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 264c960f715d..911aace42284 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -809,6 +809,9 @@ void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port) u8 learn[DSA_MAX_PORTS]; int first, index, cnt; struct ksz_port *p; + const u16 *regs; + + regs = dev->info->regs; if ((uint)port < dev->info->port_cnt) { first = port; @@ -822,9 +825,9 @@ void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port) p = &dev->ports[index]; if (!p->on) continue; - ksz_pread8(dev, index, P_STP_CTRL, &learn[index]); + ksz_pread8(dev, index, regs[P_STP_CTRL], &learn[index]); if (!(learn[index] & PORT_LEARN_DISABLE)) - ksz_pwrite8(dev, index, P_STP_CTRL, + ksz_pwrite8(dev, index, regs[P_STP_CTRL], learn[index] | PORT_LEARN_DISABLE); } ksz_cfg(dev, S_FLUSH_TABLE_CTRL, SW_FLUSH_DYN_MAC_TABLE, true); @@ -833,7 +836,7 @@ void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port) if (!p->on) continue; if (!(learn[index] & PORT_LEARN_DISABLE)) - ksz_pwrite8(dev, index, P_STP_CTRL, learn[index]); + ksz_pwrite8(dev, index, regs[P_STP_CTRL], learn[index]); } } @@ -1236,11 +1239,11 @@ void ksz8_config_cpu_port(struct dsa_switch *ds) p->fiber = 1; } if (p->fiber) - ksz_port_cfg(dev, i, P_STP_CTRL, PORT_FORCE_FLOW_CTRL, - true); + ksz_port_cfg(dev, i, regs[P_STP_CTRL], + PORT_FORCE_FLOW_CTRL, true); else - ksz_port_cfg(dev, i, P_STP_CTRL, PORT_FORCE_FLOW_CTRL, - false); + ksz_port_cfg(dev, i, regs[P_STP_CTRL], + PORT_FORCE_FLOW_CTRL, false); } } diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h index 32d985296520..a848eb4c54cb 100644 --- a/drivers/net/dsa/microchip/ksz8795_reg.h +++ b/drivers/net/dsa/microchip/ksz8795_reg.h @@ -766,7 +766,6 @@ #define P_TAG_CTRL REG_PORT_CTRL_0 #define P_MIRROR_CTRL REG_PORT_CTRL_1 #define P_802_1P_CTRL REG_PORT_CTRL_2 -#define P_STP_CTRL REG_PORT_CTRL_2 #define P_PASS_ALL_CTRL REG_PORT_CTRL_12 #define P_INS_SRC_PVID_CTRL REG_PORT_CTRL_12 #define P_DROP_TAG_CTRL REG_PORT_CTRL_13 diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index fa498ad8ca40..0e808d27124c 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -338,6 +338,7 @@ void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member) void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port) { + const u16 *regs = dev->info->regs; u8 data; regmap_update_bits(dev->regmap[0], REG_SW_LUE_CTRL_2, @@ -346,12 +347,12 @@ void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port) if (port < dev->info->port_cnt) { /* flush individual port */ - ksz_pread8(dev, port, P_STP_CTRL, &data); + ksz_pread8(dev, port, regs[P_STP_CTRL], &data); if (!(data & PORT_LEARN_DISABLE)) - ksz_pwrite8(dev, port, P_STP_CTRL, + ksz_pwrite8(dev, port, regs[P_STP_CTRL], data | PORT_LEARN_DISABLE); ksz_cfg(dev, S_FLUSH_TABLE_CTRL, SW_FLUSH_DYN_MAC_TABLE, true); - ksz_pwrite8(dev, port, P_STP_CTRL, data); + ksz_pwrite8(dev, port, regs[P_STP_CTRL], data); } else { /* flush all */ ksz_cfg(dev, S_FLUSH_TABLE_CTRL, SW_FLUSH_STP_TABLE, true); diff --git a/drivers/net/dsa/microchip/ksz9477_reg.h b/drivers/net/dsa/microchip/ksz9477_reg.h index 6be2efe6334a..2ba0f4449130 100644 --- a/drivers/net/dsa/microchip/ksz9477_reg.h +++ b/drivers/net/dsa/microchip/ksz9477_reg.h @@ -1620,7 +1620,6 @@ #define P_BCAST_STORM_CTRL REG_PORT_MAC_CTRL_0 #define P_PRIO_CTRL REG_PORT_MRI_PRIO_CTRL #define P_MIRROR_CTRL REG_PORT_MRI_MIRROR_CTRL -#define P_STP_CTRL REG_PORT_LUE_MSTP_STATE #define P_PHY_CTRL REG_PORT_PHY_CTRL #define P_RATE_LIMIT_CTRL REG_PORT_MAC_IN_RATE_LIMIT diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 4992fea208b1..2f336b991d5a 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -216,6 +216,7 @@ static const u16 ksz8795_regs[] = { [P_REMOTE_STATUS] = 0x08, [P_SPEED_STATUS] = 0x09, [S_TAIL_TAG_CTRL] = 0x0C, + [P_STP_CTRL] = 0x02, }; static const u32 ksz8795_masks[] = { @@ -266,6 +267,7 @@ static const u16 ksz8863_regs[] = { [P_REMOTE_STATUS] = 0x0E, [P_SPEED_STATUS] = 0x0F, [S_TAIL_TAG_CTRL] = 0x03, + [P_STP_CTRL] = 0x02, }; static const u32 ksz8863_masks[] = { @@ -301,6 +303,11 @@ static u8 ksz8863_shifts[] = { [DYNAMIC_MAC_SRC_PORT] = 20, }; +static const u16 ksz9477_regs[] = { + [P_STP_CTRL] = 0x0B04, + +}; + const struct ksz_chip_data ksz_switch_chips[] = { [KSZ8795] = { .chip_id = KSZ8795_CHIP_ID, @@ -318,7 +325,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8795_regs, .masks = ksz8795_masks, .shifts = ksz8795_shifts, - .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, .start_ctrl_reg = 0x01, @@ -358,7 +364,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8795_regs, .masks = ksz8795_masks, .shifts = ksz8795_shifts, - .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, .start_ctrl_reg = 0x01, @@ -384,7 +389,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8795_regs, .masks = ksz8795_masks, .shifts = ksz8795_shifts, - .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, .start_ctrl_reg = 0x01, @@ -409,7 +413,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8863_regs, .masks = ksz8863_masks, .shifts = ksz8863_shifts, - .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, .start_ctrl_reg = 0x01, @@ -431,7 +434,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300, @@ -458,7 +461,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300, @@ -484,7 +487,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300, @@ -507,7 +510,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300, @@ -532,7 +535,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300, @@ -553,7 +556,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300, @@ -574,7 +577,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300, @@ -599,7 +602,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300, @@ -624,7 +627,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300, @@ -1131,12 +1134,12 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) { struct ksz_device *dev = ds->priv; struct ksz_port *p; + const u16 *regs; u8 data; - int reg; - reg = dev->info->stp_ctrl_reg; + regs = dev->info->regs; - ksz_pread8(dev, port, reg, &data); + ksz_pread8(dev, port, regs[P_STP_CTRL], &data); data &= ~(PORT_TX_ENABLE | PORT_RX_ENABLE | PORT_LEARN_DISABLE); switch (state) { @@ -1160,7 +1163,7 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) return; } - ksz_pwrite8(dev, port, reg, data); + ksz_pwrite8(dev, port, regs[P_STP_CTRL], data); p = &dev->ports[port]; p->stp_state = state; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 18794f571687..2a9b2b59fa79 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -164,6 +164,7 @@ enum ksz_regs { P_REMOTE_STATUS, P_SPEED_STATUS, S_TAIL_TAG_CTRL, + P_STP_CTRL, }; enum ksz_masks { From patchwork Tue Jun 28 17:13:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Ramadoss X-Patchwork-Id: 12898591 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C102EC433EF for ; Tue, 28 Jun 2022 17:15:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232831AbiF1RPs (ORCPT ); Tue, 28 Jun 2022 13:15:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232847AbiF1RPl (ORCPT ); Tue, 28 Jun 2022 13:15:41 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86F392CDFF; Tue, 28 Jun 2022 10:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1656436540; x=1687972540; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J+3M0iKZHAnoFTbrr1G4kQpS3+nwFQ1xAT9f0AR8Ybg=; b=Jwb0S7/7nAJ16UAXitd0TZyiHNbgXJGUdIZzpGKPqzoNcmcdubzzQGRc NVHjqVkLgJPr0t5qoULUHoUgLnWubF70fIBaOExprmOrXakIAK6KmCtcG Q1V5Nrq8j+SghEaUXlqjxftfUa3Jpb2LDp9+37FkHoC+tXFhGc8UbDP7M qXtgvTUAG31vTU+z7EAjMZMoYlw4uZS5sDogLsFBzSCIcf4ZxKjGzB3TP yFICgFUdKADuYRaCyHrTdRxPJ5vin3oJRM4daSwOetlvAQUJNoXHzr+Wx FZpauOMCkhwiqU84wCmiSwTa+63mZsbQy4BuWUrIl7UZLOYBpUf6xiXIo Q==; X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="162448097" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Jun 2022 10:15:39 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 28 Jun 2022 10:15:31 -0700 Received: from CHE-LT-I17769U.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 28 Jun 2022 10:15:20 -0700 From: Arun Ramadoss To: , CC: Woojung Huh , , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King" Subject: [Patch net-next 7/7] net: dsa: microchip: move remaining register offset to ksz_chip_reg Date: Tue, 28 Jun 2022 22:43:29 +0530 Message-ID: <20220628171329.25503-8-arun.ramadoss@microchip.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628171329.25503-1-arun.ramadoss@microchip.com> References: <20220628171329.25503-1-arun.ramadoss@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch moves the broadcast ctrl, multicast ctrl and start control registers from ksz_chip_dat to ksz_chip_reg. Signed-off-by: Arun Ramadoss --- drivers/net/dsa/microchip/ksz_common.c | 57 +++++++------------------- drivers/net/dsa/microchip/ksz_common.h | 3 ++ 2 files changed, 18 insertions(+), 42 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 2f336b991d5a..1354804171a1 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -217,6 +217,9 @@ static const u16 ksz8795_regs[] = { [P_SPEED_STATUS] = 0x09, [S_TAIL_TAG_CTRL] = 0x0C, [P_STP_CTRL] = 0x02, + [S_START_CTRL] = 0x01, + [S_BROADCAST_CTRL] = 0x06, + [S_MULTICAST_CTRL] = 0x04, }; static const u32 ksz8795_masks[] = { @@ -268,6 +271,9 @@ static const u16 ksz8863_regs[] = { [P_SPEED_STATUS] = 0x0F, [S_TAIL_TAG_CTRL] = 0x03, [P_STP_CTRL] = 0x02, + [S_START_CTRL] = 0x01, + [S_BROADCAST_CTRL] = 0x06, + [S_MULTICAST_CTRL] = 0x04, }; static const u32 ksz8863_masks[] = { @@ -305,6 +311,9 @@ static u8 ksz8863_shifts[] = { static const u16 ksz9477_regs[] = { [P_STP_CTRL] = 0x0B04, + [S_START_CTRL] = 0x0300, + [S_BROADCAST_CTRL] = 0x0332, + [S_MULTICAST_CTRL] = 0x0331, }; @@ -325,9 +334,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8795_regs, .masks = ksz8795_masks, .shifts = ksz8795_shifts, - .broadcast_ctrl_reg = 0x06, - .multicast_ctrl_reg = 0x04, - .start_ctrl_reg = 0x01, .supports_mii = {false, false, false, false, true}, .supports_rmii = {false, false, false, false, true}, .supports_rgmii = {false, false, false, false, true}, @@ -364,9 +370,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8795_regs, .masks = ksz8795_masks, .shifts = ksz8795_shifts, - .broadcast_ctrl_reg = 0x06, - .multicast_ctrl_reg = 0x04, - .start_ctrl_reg = 0x01, .supports_mii = {false, false, false, false, true}, .supports_rmii = {false, false, false, false, true}, .supports_rgmii = {false, false, false, false, true}, @@ -389,9 +392,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8795_regs, .masks = ksz8795_masks, .shifts = ksz8795_shifts, - .broadcast_ctrl_reg = 0x06, - .multicast_ctrl_reg = 0x04, - .start_ctrl_reg = 0x01, .supports_mii = {false, false, false, false, true}, .supports_rmii = {false, false, false, false, true}, .supports_rgmii = {false, false, false, false, true}, @@ -413,9 +413,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8863_regs, .masks = ksz8863_masks, .shifts = ksz8863_shifts, - .broadcast_ctrl_reg = 0x06, - .multicast_ctrl_reg = 0x04, - .start_ctrl_reg = 0x01, .supports_mii = {false, false, true}, .supports_rmii = {false, false, true}, .internal_phy = {true, true, false}, @@ -435,9 +432,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, - .broadcast_ctrl_reg = 0x0332, - .multicast_ctrl_reg = 0x0331, - .start_ctrl_reg = 0x0300, .supports_mii = {false, false, false, false, false, true, false}, .supports_rmii = {false, false, false, false, @@ -462,9 +456,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, - .broadcast_ctrl_reg = 0x0332, - .multicast_ctrl_reg = 0x0331, - .start_ctrl_reg = 0x0300, .supports_mii = {false, false, false, false, false, true, true}, .supports_rmii = {false, false, false, false, @@ -488,9 +479,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, - .broadcast_ctrl_reg = 0x0332, - .multicast_ctrl_reg = 0x0331, - .start_ctrl_reg = 0x0300, .supports_mii = {false, false, true}, .supports_rmii = {false, false, true}, .supports_rgmii = {false, false, true}, @@ -511,9 +499,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, - .broadcast_ctrl_reg = 0x0332, - .multicast_ctrl_reg = 0x0331, - .start_ctrl_reg = 0x0300, .supports_mii = {false, false, false, false, false, true, true}, .supports_rmii = {false, false, false, false, @@ -536,9 +521,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, - .broadcast_ctrl_reg = 0x0332, - .multicast_ctrl_reg = 0x0331, - .start_ctrl_reg = 0x0300, .supports_mii = {false, false, false, false, true}, .supports_rmii = {false, false, false, false, true}, .supports_rgmii = {false, false, false, false, true}, @@ -557,9 +539,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, - .broadcast_ctrl_reg = 0x0332, - .multicast_ctrl_reg = 0x0331, - .start_ctrl_reg = 0x0300, .supports_mii = {false, false, false, false, true, true}, .supports_rmii = {false, false, false, false, true, true}, .supports_rgmii = {false, false, false, false, true, true}, @@ -578,9 +557,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, - .broadcast_ctrl_reg = 0x0332, - .multicast_ctrl_reg = 0x0331, - .start_ctrl_reg = 0x0300, .supports_mii = {false, false, false, false, true, true, false, false}, .supports_rmii = {false, false, false, false, @@ -603,9 +579,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, - .broadcast_ctrl_reg = 0x0332, - .multicast_ctrl_reg = 0x0331, - .start_ctrl_reg = 0x0300, .supports_mii = {false, false, false, false, true, true, false, false}, .supports_rmii = {false, false, false, false, @@ -628,9 +601,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, - .broadcast_ctrl_reg = 0x0332, - .multicast_ctrl_reg = 0x0331, - .start_ctrl_reg = 0x0300, .supports_mii = {false, false, false, false, true, true, false, false}, .supports_rmii = {false, false, false, false, @@ -830,8 +800,11 @@ static void ksz_update_port_member(struct ksz_device *dev, int port) static int ksz_setup(struct dsa_switch *ds) { struct ksz_device *dev = ds->priv; + const u16 *regs; int ret; + regs = dev->info->regs; + dev->vlan_cache = devm_kcalloc(dev->dev, sizeof(struct vlan_table), dev->info->num_vlans, GFP_KERNEL); if (!dev->vlan_cache) @@ -844,7 +817,7 @@ static int ksz_setup(struct dsa_switch *ds) } /* set broadcast storm protection 10% rate */ - regmap_update_bits(dev->regmap[1], dev->info->broadcast_ctrl_reg, + regmap_update_bits(dev->regmap[1], regs[S_BROADCAST_CTRL], BROADCAST_STORM_RATE, (BROADCAST_STORM_VALUE * BROADCAST_STORM_PROT_RATE) / 100); @@ -853,7 +826,7 @@ static int ksz_setup(struct dsa_switch *ds) dev->dev_ops->enable_stp_addr(dev); - regmap_update_bits(dev->regmap[0], dev->info->multicast_ctrl_reg, + regmap_update_bits(dev->regmap[0], regs[S_MULTICAST_CTRL], MULTICAST_STORM_DISABLE, MULTICAST_STORM_DISABLE); ksz_init_mib_timer(dev); @@ -867,7 +840,7 @@ static int ksz_setup(struct dsa_switch *ds) } /* start switch */ - regmap_update_bits(dev->regmap[0], dev->info->start_ctrl_reg, + regmap_update_bits(dev->regmap[0], regs[S_START_CTRL], SW_START, SW_START); return 0; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 2a9b2b59fa79..91fbb3b62536 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -165,6 +165,9 @@ enum ksz_regs { P_SPEED_STATUS, S_TAIL_TAG_CTRL, P_STP_CTRL, + S_START_CTRL, + S_BROADCAST_CTRL, + S_MULTICAST_CTRL, }; enum ksz_masks {