net: dsa: microchip: Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers
v4 cover net: dsa: microchip: Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers
From: Tristram Ha <[email protected]>
This series of patches is to modify the original KSZ9477 DSA driver so that other KSZ switch drivers can be added and use the common code.
There are several steps to accomplish this achievement. First is to rename some function names with a prefix to indicate chip specific function. Second is to move common code into header that can be shared. Last is to modify tag_ksz.c so that it can handle many tail tag formats used by different KSZ switch drivers.
ksz_common.c will contain the common code used by all KSZ switch drivers. ksz9477.c will contain KSZ9477 code from the original ksz_common.c. ksz9477_spi.c is renamed from ksz_spi.c.ksz9477_reg.h is renamed from ksz_9477_reg.h.ksz_common.h is added to provide common code access to KSZ switch drivers.ksz_spi.h is added to provide common SPI access functions to KSZ SPI drivers.
v4
- Patches were removed to concentrate on changing driver structure without adding new code.
v3
- The phy_device structure is used to hold port link information
- A structure is passed in ksz_xmit and ksz_rcv instead of function pointer
- Switch offload forwarding is supported
v2
- Initialize reg_mutex before use
- The alu_mutex is only used inside chip specific functions
v1
- Each patch in the set is self-contained
- Use ksz9477 prefix to indicate KSZ9477 specific code
Tristram Ha (6):
net: dsa: microchip: replace license with GPL
net: dsa: microchip: clean up code
net: dsa: microchip: rename some functions with ksz9477 prefix
net: dsa: microchip: rename ksz_spi.c to ksz9477_spi.c
net: dsa: microchip: break KSZ9477 DSA driver into two files
net: dsa: microchip: rename ksz_9477_reg.h to ksz9477_reg.h
drivers/net/dsa/microchip/Kconfig | 16 +-
drivers/net/dsa/microchip/Makefile | 5 +-
drivers/net/dsa/microchip/ksz9477.c | 1316 ++++++++++++++++++++
.../microchip/{ksz_9477_reg.h => ksz9477_reg.h} | 17 +-
drivers/net/dsa/microchip/ksz9477_spi.c | 177 +++
drivers/net/dsa/microchip/ksz_common.c | 1183 +++---------------
drivers/net/dsa/microchip/ksz_common.h | 214 ++++
drivers/net/dsa/microchip/ksz_priv.h | 245 ++--
drivers/net/dsa/microchip/ksz_spi.c | 217 ----
drivers/net/dsa/microchip/ksz_spi.h | 69 +
10 files changed, 2039 insertions(+), 1420 deletions(-)
create mode 100644 drivers/net/dsa/microchip/ksz9477.c
rename drivers/net/dsa/microchip/{ksz_9477_reg.h => ksz9477_reg.h} (98%)
create mode 100644 drivers/net/dsa/microchip/ksz9477_spi.c
create mode 100644 drivers/net/dsa/microchip/ksz_common.h
delete mode 100644 drivers/net/dsa/microchip/ksz_spi.c
create mode 100644 drivers/net/dsa/microchip/ksz_spi.hSignature · 1 line
1.9.1
PATCH v4 1/6 net: dsa: microchip: replace license with GPL
From: Tristram Ha <[email protected]>
Replace license with GPL.
--- drivers/net/dsa/microchip/ksz_9477_reg.h | 17 +++-------------- drivers/net/dsa/microchip/ksz_common.c | 15 ++------------- drivers/net/dsa/microchip/ksz_priv.h | 17 +++-------------- drivers/net/dsa/microchip/ksz_spi.c | 15 ++------------- 4 files changed, 10 insertions(+), 54 deletions(-)
drivers/net/dsa/microchip/ksz_9477_reg.h +3 -14
@@ -1,19 +1,8 @@ -/* -* Microchip KSZ9477 register definitions -* -* Copyright (C) 2017 +/* SPDX-License-Identifier: GPL-2.0 * -* Permission to use, copy, modify, and/or distribute this software for any -* purpose with or without fee is hereby granted, provided that the above -* copyright notice and this permission notice appear in all copies. +* Microchip KSZ9477 register definitions * -* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +* Copyright (C) 2017-2018 Microchip Technology Inc. */ #ifndef __KSZ9477_REGS_H
drivers/net/dsa/microchip/ksz_common.c +2 -13
@@ -1,19 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Microchip switch driver main logic * -* Copyright (C) 2017 -* -* Permission to use, copy, modify, and/or distribute this software for any -* purpose with or without fee is hereby granted, provided that the above -* copyright notice and this permission notice appear in all copies. -* -* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +* Copyright (C) 2017-2018 Microchip Technology Inc. */ #include <linux/delay.h>
drivers/net/dsa/microchip/ksz_priv.h +3 -14
@@ -1,19 +1,8 @@ -/* -* Microchip KSZ series switch common definitions -* -* Copyright (C) 2017 +/* SPDX-License-Identifier: GPL-2.0 * -* Permission to use, copy, modify, and/or distribute this software for any -* purpose with or without fee is hereby granted, provided that the above -* copyright notice and this permission notice appear in all copies. +* Microchip KSZ series switch common definitions * -* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +* Copyright (C) 2017-2018 Microchip Technology Inc. */ #ifndef __KSZ_PRIV_H
drivers/net/dsa/microchip/ksz_spi.c +2 -13
@@ -1,19 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Microchip KSZ series register access through SPI * -* Copyright (C) 2017 -* -* Permission to use, copy, modify, and/or distribute this software for any -* purpose with or without fee is hereby granted, provided that the above -* copyright notice and this permission notice appear in all copies. -* -* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +* Copyright (C) 2017-2018 Microchip Technology Inc. */ #include <asm/unaligned.h>
Signature · 1 line
1.9.1
PATCH v4 2/6 net: dsa: microchip: clean up code
In reply to [email protected]From: Tristram Ha <[email protected]>
Clean up code according to patch check suggestions.
--- drivers/net/dsa/microchip/ksz_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/dsa/microchip/ksz_common.c +4 -4
@@ -890,9 +890,9 @@ static void ksz_port_mdb_add(struct dsa_switch *ds, int port,if (static_table[0 ] &ALU_V_STATIC_VALID ) {/* check this has same vid & mac address */ -if (((static_table[2 ] >>ALU_V_FID_S ) == (mdb->vid)) && +if (((static_table[2 ] >>ALU_V_FID_S ) == mdb->vid) && ((static_table[2 ] &ALU_V_MAC_ADDR_HI ) == mac_hi) && - (static_table[3 ] == mac_lo)) { + static_table[3 ] == mac_lo) {/* found matching one */ break ; }
@@ -963,9 +963,9 @@ static int ksz_port_mdb_del(struct dsa_switch *ds, int port,if (static_table[0 ] &ALU_V_STATIC_VALID ) {/* check this has same vid & mac address */ -if (((static_table[2 ] >>ALU_V_FID_S ) == (mdb->vid)) && +if (((static_table[2 ] >>ALU_V_FID_S ) == mdb->vid) && ((static_table[2 ] &ALU_V_MAC_ADDR_HI ) == mac_hi) && - (static_table[3 ] == mac_lo)) { + static_table[3 ] == mac_lo) {/* found matching one */ break ; }
Signature · 1 line
1.9.1
PATCH v4 4/6 net: dsa: microchip: rename ksz_spi.c to ksz9477_spi.c
In reply to [email protected]From: Tristram Ha <[email protected]>
Rename ksz_spi.c to ksz9477_spi.c and update Kconfig in preparation to add more KSZ switch drivers.
---
drivers/net/dsa/microchip/Kconfig | 12 ++++++------
drivers/net/dsa/microchip/Makefile | 4 ++--
drivers/net/dsa/microchip/{ksz_spi.c => ksz9477_spi.c} | 0
3 files changed, 8 insertions(+), 8 deletions(-)
rename drivers/net/dsa/microchip/{ksz_spi.c => ksz9477_spi.c} (100%)drivers/net/dsa/microchip/Kconfig +6 -6
@@ -1,12 +1,12 @@ -menuconfig MICROCHIP_KSZ - tristate "Microchip KSZ series switch support" +menuconfig NET_DSA_MICROCHIP_KSZ9477 + tristate "Microchip KSZ9477 series switch support" depends on NET_DSA select NET_DSA_TAG_KSZ help - This driver adds support for Microchip KSZ switch chips. + This driver adds support for Microchip KSZ9477 switch chips. -config MICROCHIP_KSZ_SPI_DRIVER - tristate "KSZ series SPI connected switch driver" - depends on MICROCHIP_KSZ && SPI +config NET_DSA_MICROCHIP_KSZ9477_SPI + tristate "KSZ9477 series SPI connected switch driver" + depends on NET_DSA_MICROCHIP_KSZ9477 && SPI help Select to enable support for registering switches configured through SPI.
drivers/net/dsa/microchip/Makefile +2 -2
@@ -1,2 +1,2 @@ -obj-$(CONFIG_MICROCHIP_KSZ) += ksz_common.o -obj-$(CONFIG_MICROCHIP_KSZ_SPI_DRIVER) += ksz_spi.o +obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477) += ksz_common.o +obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477_SPI) += ksz9477_spi.o
drivers/net/dsa/microchip/ksz9477_spi.c renamed from drivers/net/dsa/microchip/ksz_spi.c +0 -0
Signature · 1 line
1.9.1
PATCH v4 6/6 net: dsa: microchip: rename ksz_9477_reg.h to ksz9477_reg.h
In reply to [email protected]From: Tristram Ha <[email protected]>
Rename ksz_9477_reg.h to ksz9477_reg.h for consistency as the product name is always KSZ####.
---
drivers/net/dsa/microchip/ksz9477.c | 2 +-
drivers/net/dsa/microchip/{ksz_9477_reg.h => ksz9477_reg.h} | 0
drivers/net/dsa/microchip/ksz_priv.h | 2 +-
3 files changed, 2 insertions(+), 2 deletions(-)
rename drivers/net/dsa/microchip/{ksz_9477_reg.h => ksz9477_reg.h} (100%)drivers/net/dsa/microchip/ksz9477.c +1 -1
@@ -19,7 +19,7 @@#include "ksz_priv.h" #include "ksz_common.h" -#include "ksz_9477_reg.h" +#include "ksz9477_reg.h" static const struct { int index;
drivers/net/dsa/microchip/ksz9477_reg.h renamed from drivers/net/dsa/microchip/ksz_9477_reg.h +0 -0
drivers/net/dsa/microchip/ksz_priv.h +1 -1
@@ -14,7 +14,7 @@#include <linux/etherdevice.h> #include <net/dsa.h> -#include "ksz_9477_reg.h" +#include "ksz9477_reg.h" struct ksz_io_ops ;
Signature · 1 line
1.9.1
PATCH v4 3/6 net: dsa: microchip: rename some functions with ksz9477 prefix
In reply to [email protected]From: Tristram Ha <[email protected]>
Rename some functions with ksz9477 prefix to separate chip specific code from common code.
--- drivers/net/dsa/microchip/ksz_common.c | 116 +++++++++++++++++---------------- 1 file changed, 59 insertions(+), 57 deletions(-)
drivers/net/dsa/microchip/ksz_common.c +59 -57
@@ -253,9 +253,8 @@ static int wait_alu_sta_ready(struct ksz_device *dev, u32 waiton, int timeout)return 0 ; } -static int ksz_reset_switch (struct dsa_switch *ds) +static int ksz9477_reset_switch (struct ksz_device *dev) { -struct ksz_device *dev = ds->priv;u8 data8;u16 data16;u32 data32;
@@ -288,7 +287,7 @@ static int ksz_reset_switch(struct dsa_switch *ds)return 0 ; } -static void port_setup (struct ksz_device *dev,int port,bool cpu_port) +static void ksz9477_port_setup (struct ksz_device *dev,int port,bool cpu_port) {u8 data8;u16 data16;
@@ -334,7 +333,7 @@ static void port_setup(struct ksz_device *dev, int port, bool cpu_port)ksz_pread16 (dev, port,REG_PORT_PHY_INT_ENABLE , &data16); } -static void ksz_config_cpu_port (struct dsa_switch *ds) +static void ksz9477_config_cpu_port (struct dsa_switch *ds) {struct ksz_device *dev = ds->priv;int i;
@@ -346,12 +345,12 @@ static void ksz_config_cpu_port(struct dsa_switch *ds) dev->cpu_port = i;/* enable cpu port */ -port_setup (dev, i, true); +ksz9477_port_setup (dev, i, true); } } } -static int ksz_setup (struct dsa_switch *ds) +static int ksz9477_setup (struct dsa_switch *ds) {struct ksz_device *dev = ds->priv;int ret =0 ;
@@ -361,7 +360,7 @@ static int ksz_setup(struct dsa_switch *ds)if (!dev->vlan_cache)return -ENOMEM ; - ret =ksz_reset_switch (ds); + ret =ksz9477_reset_switch (dev);if (ret) {dev_err (ds->dev,"failed to reset switch\n" );return ret;
@@ -370,7 +369,7 @@ static int ksz_setup(struct dsa_switch *ds)/* accept packet up to 2000bytes */ ksz_cfg (dev,REG_SW_MAC_CTRL_1 ,SW_LEGAL_PACKET_DISABLE , true); -ksz_config_cpu_port (ds); +ksz9477_config_cpu_port (ds);ksz_cfg (dev,REG_SW_MAC_CTRL_1 ,MULTICAST_STORM_DISABLE , true);
@@ -383,13 +382,13 @@ static int ksz_setup(struct dsa_switch *ds)return 0 ; } -static enum dsa_tag_protocol ksz_get_tag_protocol (struct dsa_switch *ds, -int port) +static enum dsa_tag_protocol ksz9477_get_tag_protocol (struct dsa_switch *ds, +int port) {return DSA_TAG_PROTO_KSZ ; } -static int ksz_phy_read16 (struct dsa_switch *ds,int addr,int reg) +static int ksz9477_phy_read16 (struct dsa_switch *ds,int addr,int reg) {struct ksz_device *dev = ds->priv;u16 val =0 ;
@@ -399,7 +398,8 @@ static int ksz_phy_read16(struct dsa_switch *ds, int addr, int reg)return val; } -static int ksz_phy_write16 (struct dsa_switch *ds,int addr,int reg,u16 val) +static int ksz9477_phy_write16 (struct dsa_switch *ds,int addr,int reg, +u16 val) {struct ksz_device *dev = ds->priv;
@@ -414,7 +414,7 @@ static int ksz_enable_port(struct dsa_switch *ds, int port,struct ksz_device *dev = ds->priv;/* setup slave port */ -port_setup (dev, port, false); +ksz9477_port_setup (dev, port, false);return 0 ; }
@@ -436,8 +436,8 @@ static int ksz_sset_count(struct dsa_switch *ds, int port, int sset)return TOTAL_SWITCH_COUNTER_NUM ; } -static void ksz_get_strings (struct dsa_switch *ds,int port, -u32 stringset,uint8_t *buf) +static void ksz9477_get_strings (struct dsa_switch *ds,int port, +u32 stringset,uint8_t *buf) {int i;
@@ -490,7 +490,8 @@ static void ksz_get_ethtool_stats(struct dsa_switch *ds, int port,mutex_unlock (&dev->stats_mutex); } -static void ksz_port_stp_state_set (struct dsa_switch *ds,int port,u8 state) +static void ksz9477_port_stp_state_set (struct dsa_switch *ds,int port, +u8 state) {struct ksz_device *dev = ds->priv;u8 data;
@@ -535,7 +536,8 @@ static void ksz_port_fast_age(struct dsa_switch *ds, int port)ksz_write8 (dev,REG_SW_LUE_CTRL_1 , data8); } -static int ksz_port_vlan_filtering (struct dsa_switch *ds,int port,bool flag) +static int ksz9477_port_vlan_filtering (struct dsa_switch *ds,int port, +bool flag) {struct ksz_device *dev = ds->priv;
@@ -562,8 +564,8 @@ static int ksz_port_vlan_prepare(struct dsa_switch *ds, int port,return 0 ; } -static void ksz_port_vlan_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +static void ksz9477_port_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {struct ksz_device *dev = ds->priv;u32 vlan_table[3 ];
@@ -596,8 +598,8 @@ static void ksz_port_vlan_add(struct dsa_switch *ds, int port, } } -static int ksz_port_vlan_del (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_vlan *vlan) +static int ksz9477_port_vlan_del (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan) {struct ksz_device *dev = ds->priv;bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;
@@ -652,8 +654,8 @@ struct alu_struct {u8 mac[ETH_ALEN ]; }; -static int ksz_port_fdb_add (struct dsa_switch *ds,int port, -const unsigned char *addr,u16 vid) +static int ksz9477_port_fdb_add (struct dsa_switch *ds,int port, +const unsigned char *addr,u16 vid) {struct ksz_device *dev = ds->priv;u32 alu_table[4 ];
@@ -709,8 +711,8 @@ static int ksz_port_fdb_add(struct dsa_switch *ds, int port,return ret; } -static int ksz_port_fdb_del (struct dsa_switch *ds,int port, -const unsigned char *addr,u16 vid) +static int ksz9477_port_fdb_del (struct dsa_switch *ds,int port, +const unsigned char *addr,u16 vid) {struct ksz_device *dev = ds->priv;u32 alu_table[4 ];
@@ -799,8 +801,8 @@ static void convert_alu(struct alu_struct *alu, u32 *alu_table) alu->mac[5 ] = alu_table[3 ] &0xFF ; } -static int ksz_port_fdb_dump (struct dsa_switch *ds,int port, -dsa_fdb_dump_cb_t *cb,void *data) +static int ksz9477_port_fdb_dump (struct dsa_switch *ds,int port, +dsa_fdb_dump_cb_t *cb,void *data) {struct ksz_device *dev = ds->priv;int ret =0 ;
@@ -858,8 +860,8 @@ static int ksz_port_mdb_prepare(struct dsa_switch *ds, int port,return 0 ; } -static void ksz_port_mdb_add (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) +static void ksz9477_port_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb) {struct ksz_device *dev = ds->priv;u32 static_table[4 ];
@@ -928,8 +930,8 @@ static void ksz_port_mdb_add(struct dsa_switch *ds, int port,mutex_unlock (&dev->alu_mutex); } -static int ksz_port_mdb_del (struct dsa_switch *ds,int port, -const struct switchdev_obj_port_mdb *mdb) +static int ksz9477_port_mdb_del (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb) {struct ksz_device *dev = ds->priv;u32 static_table[4 ];
@@ -1005,9 +1007,9 @@ static int ksz_port_mdb_del(struct dsa_switch *ds, int port,return ret; } -static int ksz_port_mirror_add (struct dsa_switch *ds,int port, -struct dsa_mall_mirror_tc_entry *mirror, -bool ingress) +static int ksz9477_port_mirror_add (struct dsa_switch *ds,int port, +struct dsa_mall_mirror_tc_entry *mirror, +bool ingress) {struct ksz_device *dev = ds->priv;
@@ -1027,8 +1029,8 @@ static int ksz_port_mirror_add(struct dsa_switch *ds, int port,return 0 ; } -static void ksz_port_mirror_del (struct dsa_switch *ds,int port, -struct dsa_mall_mirror_tc_entry *mirror) +static void ksz9477_port_mirror_del (struct dsa_switch *ds,int port, +struct dsa_mall_mirror_tc_entry *mirror) {struct ksz_device *dev = ds->priv;u8 data;
@@ -1046,29 +1048,29 @@ static void ksz_port_mirror_del(struct dsa_switch *ds, int port, }static const struct dsa_switch_ops ksz_switch_ops = { - .get_tag_protocol = ksz_get_tag_protocol, - .setup = ksz_setup, - .phy_read = ksz_phy_read16, - .phy_write = ksz_phy_write16, + .get_tag_protocol = ksz9477_get_tag_protocol, + .setup = ksz9477_setup, + .phy_read = ksz9477_phy_read16, + .phy_write = ksz9477_phy_write16, .port_enable = ksz_enable_port, .port_disable = ksz_disable_port, - .get_strings = ksz_get_strings, + .get_strings = ksz9477_get_strings, .get_ethtool_stats = ksz_get_ethtool_stats, .get_sset_count = ksz_sset_count, - .port_stp_state_set = ksz_port_stp_state_set, + .port_stp_state_set = ksz9477_port_stp_state_set, .port_fast_age = ksz_port_fast_age, - .port_vlan_filtering = ksz_port_vlan_filtering, + .port_vlan_filtering = ksz9477_port_vlan_filtering, .port_vlan_prepare = ksz_port_vlan_prepare, - .port_vlan_add = ksz_port_vlan_add, - .port_vlan_del = ksz_port_vlan_del, - .port_fdb_dump = ksz_port_fdb_dump, - .port_fdb_add = ksz_port_fdb_add, - .port_fdb_del = ksz_port_fdb_del, + .port_vlan_add = ksz9477_port_vlan_add, + .port_vlan_del = ksz9477_port_vlan_del, + .port_fdb_dump = ksz9477_port_fdb_dump, + .port_fdb_add = ksz9477_port_fdb_add, + .port_fdb_del = ksz9477_port_fdb_del, .port_mdb_prepare = ksz_port_mdb_prepare, - .port_mdb_add = ksz_port_mdb_add, - .port_mdb_del = ksz_port_mdb_del, - .port_mirror_add = ksz_port_mirror_add, - .port_mirror_del = ksz_port_mirror_del, + .port_mdb_add = ksz9477_port_mdb_add, + .port_mdb_del = ksz9477_port_mdb_del, + .port_mirror_add = ksz9477_port_mirror_add, + .port_mirror_del = ksz9477_port_mirror_del, };struct ksz_chip_data {
@@ -1081,7 +1083,7 @@ struct ksz_chip_data {int port_cnt; }; -static const struct ksz_chip_data ksz_switch_chips[] = { +static const struct ksz_chip_data ksz9477_switch_chips[] = { { .chip_id =0x00947700 , .dev_name ="KSZ9477" ,
@@ -1102,14 +1104,14 @@ struct ksz_chip_data { }, }; -static int ksz_switch_init (struct ksz_device *dev) +static int ksz9477_switch_init (struct ksz_device *dev) {int i; dev->ds->ops = &ksz_switch_ops; -for (i =0 ; i <ARRAY_SIZE (ksz_switch_chips); i++) { -const struct ksz_chip_data *chip = &ksz_switch_chips[i]; +for (i =0 ; i <ARRAY_SIZE (ksz9477_switch_chips); i++) { +const struct ksz_chip_data *chip = &ksz9477_switch_chips[i];if (dev->chip_id == chip->chip_id) { dev->name = chip->dev_name;
@@ -1198,7 +1200,7 @@ int ksz_switch_register(struct ksz_device *dev)if (ksz_switch_detect (dev))return -EINVAL ; - ret =ksz_switch_init (dev); + ret =ksz9477_switch_init (dev);if (ret)return ret;
Signature · 1 line
1.9.1
PATCH v4 5/6 net: dsa: microchip: break KSZ9477 DSA driver into two files
In reply to [email protected]From: Tristram Ha <[email protected]>
Break KSZ9477 DSA driver into two files in preparation to add more KSZ switch drivers.
Add common functions in ksz_common.h so that other KSZ switch drivers can access code in ksz_common.c.
Add ksz_spi.h for common functions used by KSZ switch SPI drivers.
--- drivers/net/dsa/microchip/Kconfig | 4 + drivers/net/dsa/microchip/Makefile | 3 +- drivers/net/dsa/microchip/ksz9477.c | 1316 +++++++++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz9477_spi.c | 143 ++-- drivers/net/dsa/microchip/ksz_common.c | 1170 ++++----------------------- drivers/net/dsa/microchip/ksz_common.h | 214 +++++ drivers/net/dsa/microchip/ksz_priv.h | 226 +++--- drivers/net/dsa/microchip/ksz_spi.h | 69 ++ 8 files changed, 1903 insertions(+), 1242 deletions(-) create mode 100644 drivers/net/dsa/microchip/ksz9477.c create mode 100644 drivers/net/dsa/microchip/ksz_common.h create mode 100644 drivers/net/dsa/microchip/ksz_spi.h
drivers/net/dsa/microchip/Kconfig +4 -0
@@ -1,7 +1,11 @@ +config NET_DSA_MICROCHIP_KSZ_COMMON + tristate + menuconfig NET_DSA_MICROCHIP_KSZ9477 tristate "Microchip KSZ9477 series switch support" depends on NET_DSA select NET_DSA_TAG_KSZ + select NET_DSA_MICROCHIP_KSZ_COMMON help This driver adds support for Microchip KSZ9477 switch chips.
drivers/net/dsa/microchip/Makefile +2 -1
@@ -1,2 +1,3 @@ -obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477) += ksz_common.o +obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON) += ksz_common.o +obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477) += ksz9477.o obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477_SPI) += ksz9477_spi.o
drivers/net/dsa/microchip/ksz9477.c new file +1316 -0
1,316 lines not on this page · raw message
drivers/net/dsa/microchip/ksz9477_spi.c +57 -86
229 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_common.c +144 -1026
1,320 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_common.h new file +214 -0
120 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_priv.h +97 -129
226 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_spi.h new file +69 -0
69 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.9.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v4 net-next 6/6] net: dsa: microchip: rename ksz_9477_reg.h to ksz9477_reg.h
In reply to [email protected]Quoted 8 lines · On 11/20/2018 3:55 PM, [email protected] wrote:
From: Tristram Ha <[email protected]>
Rename
ksz_9477_reg.htoksz9477_reg.hfor consistency as the product name is always KSZ####.Signed-off-by Tristram Ha <[email protected]>Reviewed-by Woojung Huh <[email protected]>Reviewed-by Andrew Lunn <[email protected]>
Signature · 1 line
Florian
Re: [PATCH v4 net-next 1/6] net: dsa: microchip: replace license with GPL
In reply to [email protected]Quoted 8 lines · On 11/20/2018 3:55 PM, [email protected] wrote:
From: Tristram Ha <[email protected]>
Replace license with GPL.
Signed-off-by Tristram Ha <[email protected]>Reviewed-by Woojung Huh <[email protected]>Reviewed-by Andrew Lunn <[email protected]>Acked-by Pavel Machek <[email protected]>
Signature · 1 line
Florian
Quoted 11 lines · On 11/20/2018 3:55 PM, [email protected] wrote:
From: Tristram Ha <[email protected]>
This series of patches is to modify the original KSZ9477 DSA driver so that other KSZ switch drivers can be added and use the common code.
There are several steps to accomplish this achievement. First is to rename some function names with a prefix to indicate chip specific function. Second is to move common code into header that can be shared. Last is to modify
tag_ksz.cso that it can handle many tail tag formats used by different KSZ switch drivers.
Quoted 8 lines
ksz_common.cwill contain the common code used by all KSZ switch drivers.ksz9477.cwill contain KSZ9477 code from the originalksz_common.c.ksz9477_spi.cis renamed fromksz_spi.c.ksz9477_reg.his renamed fromksz_9477_reg.h.ksz_common.his added to provide common code access to KSZ switch drivers.ksz_spi.his added to provide common SPI access functions to KSZ SPI drivers.
Thanks a lot for getting this series out, hopefully there is no blocker getting it merged now and you can follow-up with additional features.
Quoted 44 lines
v4
- Patches were removed to concentrate on changing driver structure without adding new code.v3
- Thephy_devicestructure is used to hold port link information
- A structure is passed inksz_xmitandksz_rcvinstead of function pointer
- Switch offload forwarding is supportedv2
- Initializereg_mutexbefore use
- Thealu_mutexis only used inside chip specific functionsv1
- Each patch in the set is self-contained
- Use ksz9477 prefix to indicate KSZ9477 specific codeTristram Ha (6):
net: dsa: microchip: replace license with GPL
net: dsa: microchip: clean up code
net: dsa: microchip: rename some functions with ksz9477 prefix
net: dsa: microchip: renameksz_spi.ctoksz9477_spi.c
net: dsa: microchip: break KSZ9477 DSA driver into two files
net: dsa: microchip: renameksz_9477_reg.htoksz9477_reg.hdrivers/net/dsa/microchip/Kconfig | 16 +- drivers/net/dsa/microchip/Makefile | 5 +- drivers/net/dsa/microchip/ksz9477.c | 1316 ++++++++++++++++++++ .../microchip/{ksz_9477_reg.h => ksz9477_reg.h} | 17 +- drivers/net/dsa/microchip/ksz9477_spi.c | 177 +++ drivers/net/dsa/microchip/ksz_common.c | 1183 +++--------------- drivers/net/dsa/microchip/ksz_common.h | 214 ++++ drivers/net/dsa/microchip/ksz_priv.h | 245 ++-- drivers/net/dsa/microchip/ksz_spi.c | 217 ---- drivers/net/dsa/microchip/ksz_spi.h | 69 + 10 files changed, 2039 insertions(+), 1420 deletions(-) create mode 100644 drivers/net/dsa/microchip/ksz9477.c rename drivers/net/dsa/microchip/{ksz_9477_reg.h => ksz9477_reg.h} (98%) create mode 100644 drivers/net/dsa/microchip/ksz9477_spi.c create mode 100644 drivers/net/dsa/microchip/ksz_common.h delete mode 100644 drivers/net/dsa/microchip/ksz_spi.c create mode 100644 drivers/net/dsa/microchip/ksz_spi.h
Signature · 1 line
Florian
David Miller
maintainerFrom: <[email protected]>
Date: Tue, 20 Nov 2018 15:55:04 -0800
Quoted 2 lines
This series of patches is to modify the original KSZ9477 DSA driver so that other KSZ switch drivers can be added and use the common code.
Series applied.
Re: [PATCH v4 net-next 5/6] net: dsa: microchip: break KSZ9477 DSA driver into two files
In reply to [email protected]Quoted 7 lines · On Tue, 2018-11-20 at 15:55 -0800, [email protected] wrote:
From: Tristram Ha <[email protected]>
Break KSZ9477 DSA driver into two files in preparation to add more KSZ switch drivers.
Add common functions inksz_common.hso that other KSZ switch drivers can access code inksz_common.c.
Addksz_spi.hfor common functions used by KSZ switch SPI drivers.
With this patch, the ethernet on my EVB-KSZ9477 is now completely non- functional, link is detected on the LAN ports, but no packets are forwarded to/from the CPU port.
Looking through the patch, it does much more than splitting up the existing code, e.g. the PORT_VLAN_MEMBERSHIP register is now written to
- I suspect that change may be responsible for the problem.
Stefan
RE: [PATCH v4 net-next 5/6] net: dsa: microchip: break KSZ9477 DSA driver into two files
Quoted 18 lines
From: Sørensen, Stefan <[email protected]>
Sent: Monday, December 03, 2018 5:50 AM
To: [email protected]; Tristram Ha - C24268 <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; UNGLinuxDriver <[email protected]>; [email protected]
Subject: Re: [PATCH v4 net-next 5/6] net: dsa: microchip: break KSZ9477 DSA driver into two filesQuoted 7 lines · On Tue, 2018-11-20 at 15:55 -0800, [email protected] wrote:
From: Tristram Ha <[email protected]>
Break KSZ9477 DSA driver into two files in preparation to add more KSZ switch drivers.
Add common functions inksz_common.hso that other KSZ switch drivers can access code inksz_common.c.
Addksz_spi.hfor common functions used by KSZ switch SPI drivers.
Quoted 8 lines
With this patch, the ethernet on my EVB-KSZ9477 is now completely non- functional, link is detected on the LAN ports, but no packets are forwarded to/from the CPU port.
Looking through the patch, it does much more than splitting up the existing code, e.g. the
PORT_VLAN_MEMBERSHIPregister is now written to
- I suspect that change may be responsible for the problem.
It is more likely the RGMII interface is not set properly. There are upcoming patches that address this issue. The primary way to set RGMII delay is to set phy-mode to "rgmii-txid" inside the device tree under the ksz9477 definition. The chip can be set to MII/RMII with strap options, but there is no way to change RGMII delay settings.
The patch will try to get the mode from hardware first. When it is not set in device tree this mode will be used. When it is different from the one set a warning will be displayed. The one from device tree will be the one to use.
This will patch will support KSZ9893, a 3-port variant of KSZ9477. It shares most of the registers but has a different tail tag format, and uses a different RGMII setting in the evaluation board.
Or do you use a different CPU port rather than the default port 6?