Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers
cover 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.
v1
- Each patch in the set is self-contained
- Use ksz9477 prefix to indicate KSZ9477 specific code
- Simplify MIB counter reading code
- Switch driver code is not accessed from tag_ksz.c
Tristram Ha (7):
Replace license with GPL.
Clean up code according to patch check suggestions.
Rename some functions with ksz9477 prefix to separate chip specific
code from common code.
Rename ksz_spi.c to ksz9477_spi.c and update Kconfig in preparation to
add more KSZ switch drivers.
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.
Add MIB counter reading support. Rename ksz_9477_reg.h to
ksz9477_reg.h for consistency as the product name is always KSZ####. Header file ksz_priv.h no longer contains any chip specific data.
Modify tag_ksz.c so that tail tag code can be used by other KSZ switch
drivers.
drivers/net/dsa/microchip/Kconfig | 14 +-
drivers/net/dsa/microchip/Makefile | 4 +-
drivers/net/dsa/microchip/ksz9477.c | 1376 ++++++++++++++++++++
.../microchip/{ksz_9477_reg.h => ksz9477_reg.h} | 23 +-
drivers/net/dsa/microchip/ksz9477_spi.c | 188 +++
drivers/net/dsa/microchip/ksz_common.c | 1210 ++++-------------
drivers/net/dsa/microchip/ksz_common.h | 234 ++++
drivers/net/dsa/microchip/ksz_priv.h | 258 ++--
drivers/net/dsa/microchip/ksz_spi.c | 216 ---
drivers/net/dsa/microchip/ksz_spi.h | 82 ++
include/net/dsa.h | 2 +-
net/dsa/Kconfig | 4 +
net/dsa/dsa.c | 4 +-
net/dsa/dsa_priv.h | 2 +-
net/dsa/tag_ksz.c | 107 +-
15 files changed, 2331 insertions(+), 1393 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
RFC PATCH 1/7 Replace license with GPL
From: Tristram Ha <[email protected]>
Replace license with GPL.
--- drivers/net/dsa/microchip/ksz_9477_reg.h | 23 ++++++++++++----------- drivers/net/dsa/microchip/ksz_common.c | 23 ++++++++++++----------- drivers/net/dsa/microchip/ksz_priv.h | 23 ++++++++++++----------- drivers/net/dsa/microchip/ksz_spi.c | 23 ++++++++++++----------- 4 files changed, 48 insertions(+), 44 deletions(-)
drivers/net/dsa/microchip/ksz_9477_reg.h +12 -11
@@ -1,19 +1,20 @@/* * Microchip KSZ9477 register definitions * -* Copyright (C) 2017 +* Copyright (C) 2017 Microchip Technology Inc. * -* 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. +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. * -* 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. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. */ #ifndef __KSZ9477_REGS_H
drivers/net/dsa/microchip/ksz_common.c +12 -11
@@ -1,19 +1,20 @@/* * Microchip switch driver main logic * -* Copyright (C) 2017 +* Copyright (C) 2017 Microchip Technology Inc. * -* 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. +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. * -* 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. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include <linux/delay.h>
drivers/net/dsa/microchip/ksz_priv.h +12 -11
@@ -1,19 +1,20 @@/* * Microchip KSZ series switch common definitions * -* Copyright (C) 2017 +* Copyright (C) 2017 Microchip Technology Inc. * -* 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. +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. * -* 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. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. */ #ifndef __KSZ_PRIV_H
drivers/net/dsa/microchip/ksz_spi.c +12 -11
@@ -1,19 +1,20 @@/* * Microchip KSZ series register access through SPI * -* Copyright (C) 2017 +* Copyright (C) 2017 Microchip Technology Inc. * -* 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. +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. * -* 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. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include <asm/unaligned.h>
Signature · 1 line
1.9.1
RFC PATCH 2/7 Clean up code according to patch check suggestions
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
@@ -898,9 +898,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 ; }
@@ -971,9 +971,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
RFC PATCH 3/7 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
@@ -265,9 +265,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;
@@ -300,7 +299,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;
@@ -346,7 +345,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;
@@ -358,12 +357,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 ;
@@ -373,7 +372,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;
@@ -382,7 +381,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);
@@ -395,12 +394,12 @@ static int ksz_setup(struct dsa_switch *ds)return 0 ; } -static enum dsa_tag_protocol ksz_get_tag_protocol (struct dsa_switch *ds) +static enum dsa_tag_protocol ksz9477_get_tag_protocol (struct dsa_switch *ds) {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 ;
@@ -410,7 +409,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;
@@ -425,7 +425,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 ; }
@@ -444,7 +444,7 @@ static int ksz_sset_count(struct dsa_switch *ds)return TOTAL_SWITCH_COUNTER_NUM ; } -static void ksz_get_strings (struct dsa_switch *ds,int port,uint8_t *buf) +static void ksz9477_get_strings (struct dsa_switch *ds,int port,uint8_t *buf) {int i;
@@ -494,7 +494,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;
@@ -539,7 +540,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;
@@ -567,9 +569,9 @@ 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, -struct switchdev_trans *trans) +static void ksz9477_port_vlan_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_vlan *vlan, +struct switchdev_trans *trans) {struct ksz_device *dev = ds->priv;u32 vlan_table[3 ];
@@ -602,8 +604,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 ;
@@ -658,8 +660,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 ];
@@ -715,8 +717,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 ];
@@ -805,8 +807,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 ;
@@ -865,9 +867,9 @@ 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, -struct switchdev_trans *trans) +static void ksz9477_port_mdb_add (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb, +struct switchdev_trans *trans) {struct ksz_device *dev = ds->priv;u32 static_table[4 ];
@@ -936,8 +938,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 ];
@@ -1013,9 +1015,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;
@@ -1035,8 +1037,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;
@@ -1054,29 +1056,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 {
@@ -1089,7 +1091,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" ,
@@ -1101,7 +1103,7 @@ struct ksz_chip_data { }, }; -static int ksz_switch_init (struct ksz_device *dev) +static int ksz9477_switch_init (struct ksz_device *dev) {int i;
@@ -1112,8 +1114,8 @@ static int ksz_switch_init(struct ksz_device *dev) 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;
@@ -1197,7 +1199,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
RFC PATCH 4/7 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 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 MICROCHIP_KSZ9477_SPI_DRIVER + tristate "KSZ9477 series SPI connected switch driver" + depends on 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_MICROCHIP_KSZ9477) += ksz_common.o +obj-$(CONFIG_MICROCHIP_KSZ9477_SPI_DRIVER) += 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
RFC PATCH 5/7 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/Makefile | 2 +- drivers/net/dsa/microchip/ksz9477.c | 1328 +++++++++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz9477_spi.c | 143 ++-- drivers/net/dsa/microchip/ksz_common.c | 1133 +++----------------------- drivers/net/dsa/microchip/ksz_common.h | 230 ++++++ drivers/net/dsa/microchip/ksz_priv.h | 229 +++--- drivers/net/dsa/microchip/ksz_spi.h | 82 ++ 7 files changed, 1926 insertions(+), 1221 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/Makefile +1 -1
@@ -1,2 +1,2 @@ -obj-$(CONFIG_MICROCHIP_KSZ9477) += ksz_common.o +obj-$(CONFIG_MICROCHIP_KSZ9477) += ksz9477.o ksz_common.o obj-$(CONFIG_MICROCHIP_KSZ9477_SPI_DRIVER) += ksz9477_spi.o
drivers/net/dsa/microchip/ksz9477.c new file +1328 -0
1,328 lines not on this page · raw message
drivers/net/dsa/microchip/ksz9477_spi.c +57 -86
227 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_common.c +128 -1005
1,290 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_common.h new file +230 -0
152 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_priv.h +100 -129
229 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_spi.h new file +82 -0
82 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.
RFC PATCH 6/7 Add MIB counter reading support
In reply to [email protected]From: Tristram Ha <[email protected]>
Add MIB counter reading support.
Rename ksz_9477_reg.h to ksz9477_reg.h for consistency as the product name is always KSZ####.
Header file ksz_priv.h no longer contains any chip specific data.
---
drivers/net/dsa/microchip/ksz9477.c | 130 ++++++++++++++-------
.../microchip/{ksz_9477_reg.h => ksz9477_reg.h} | 0
drivers/net/dsa/microchip/ksz_common.c | 122 +++++++++++++++++++
drivers/net/dsa/microchip/ksz_common.h | 4 +
drivers/net/dsa/microchip/ksz_priv.h | 8 +-
5 files changed, 219 insertions(+), 45 deletions(-)
rename drivers/net/dsa/microchip/{ksz_9477_reg.h => ksz9477_reg.h} (100%)drivers/net/dsa/microchip/ksz9477.c +89 -41
@@ -31,7 +31,7 @@#include "ksz_priv.h" #include "ksz_common.h" -#include "ksz_9477_reg.h" +#include "ksz9477_reg.h" static const struct { int index;
@@ -272,6 +272,74 @@ static int ksz9477_reset_switch(struct ksz_device *dev)return 0 ; } +static void ksz9477_r_mib_cnt (struct ksz_device *dev,int port,u16 addr, +u64 *cnt) +{ +u32 data; +int timeout; + +/* retain the flush/freeze bit */ +ksz_pread32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 , &data); + data &=MIB_COUNTER_FLUSH_FREEZE ; + + data |=MIB_COUNTER_READ ; + data |= (addr <<MIB_COUNTER_INDEX_S ); +ksz_pwrite32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 , data); + + timeout =1000 ; +do { +ksz_pread32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 , + &data); +usleep_range (1 ,10 ); +if (!(data &MIB_COUNTER_READ )) +break ; + }while (timeout-- >0 ); + +/* failed to read MIB. get out of loop */ +if (!timeout) { +dev_dbg (dev->dev,"Failed to get MIB\n" ); +return ; + } + +/* count resets upon read */ +ksz_pread32 (dev, port,REG_PORT_MIB_DATA , &data); + *cnt += data; +} + +static void ksz9477_r_mib_pkt (struct ksz_device *dev,int port,u16 addr, +u64 *dropped,u64 *cnt) +{ + addr = mib_names[addr].index; +ksz9477_r_mib_cnt (dev, port, addr, cnt); +} + +static void ksz9477_freeze_mib (struct ksz_device *dev,int port,bool freeze) +{ +/* enable the port for flush/freeze function */ +if (freeze) +ksz_pwrite32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 , +MIB_COUNTER_FLUSH_FREEZE ); +ksz_cfg (dev,REG_SW_MAC_CTRL_6 ,SW_MIB_COUNTER_FREEZE , freeze); + +/* disable the port after freeze is done */ +if (!freeze) +ksz_pwrite32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 ,0 ); +} + +static void ksz9477_port_init_cnt (struct ksz_device *dev,int port) +{ +struct ksz_port_mib *mib = &dev->ports[port].mib; + +/* flush all enabled port MIB counters */ +ksz_pwrite32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 , +MIB_COUNTER_FLUSH_FREEZE ); +ksz_write8 (dev,REG_SW_MAC_CTRL_6 ,SW_MIB_COUNTER_FLUSH ); +ksz_pwrite32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 ,0 ); + + mib->cnt_ptr =0 ; +memset (mib->counters,0 , dev->mib_cnt *sizeof (u64)); +} +static enum dsa_tag_protocol ksz9477_get_tag_protocol (struct dsa_switch *ds) {return DSA_TAG_PROTO_KSZ ;
@@ -350,46 +418,6 @@ static void ksz9477_get_strings(struct dsa_switch *ds, int port, uint8_t *buf) } } -static void ksz_get_ethtool_stats (struct dsa_switch *ds,int port, -uint64_t *buf) -{ -struct ksz_device *dev = ds->priv; -int i; -u32 data; -int timeout; - -mutex_lock (&dev->stats_mutex); - -for (i =0 ; i <TOTAL_SWITCH_COUNTER_NUM ; i++) { - data =MIB_COUNTER_READ ; - data |= ((mib_names[i].index &0xFF ) <<MIB_COUNTER_INDEX_S ); -ksz_pwrite32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 , data); - - timeout =1000 ; -do { -ksz_pread32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 , - &data); -usleep_range (1 ,10 ); -if (!(data &MIB_COUNTER_READ )) -break ; - }while (timeout-- >0 ); - -/* failed to read MIB. get out of loop */ -if (!timeout) { -dev_dbg (dev->dev,"Failed to get MIB\n" ); -break ; - } - -/* count resets upon read */ -ksz_pread32 (dev, port,REG_PORT_MIB_DATA , &data); - - dev->mib_value[i] += (uint64_t )data; - buf[i] = dev->mib_value[i]; - } - -mutex_unlock (&dev->stats_mutex); -} -static void ksz9477_cfg_port_member (struct ksz_device *dev,int port,u8 member) {
@@ -977,6 +1005,17 @@ static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port, PORT_MIRROR_SNIFFER, false); } +static void ksz9477_phy_setup (struct ksz_device *dev,int port, +struct phy_device *phy) +{ +if (port < dev->phy_port_cnt) { +/* SUPPORTED_Asym_Pause and SUPPORTED_Pause can be removed to +* disable flow control when rate limiting is used. +*/ + phy->advertising = phy->supported; + } +} +static void ksz9477_port_setup (struct ksz_device *dev,int port,bool cpu_port) {u8 data8;
@@ -1159,6 +1198,8 @@ static int ksz9477_setup(struct dsa_switch *ds)/* start switch */ ksz_cfg (dev,REG_SW_OPERATION ,SW_START , true); +ksz_init_mib_timer (dev); +return 0 ; }
@@ -1168,6 +1209,7 @@ static int ksz9477_setup(struct dsa_switch *ds) .set_addr = ksz9477_set_addr, .phy_read = ksz9477_phy_read16, .phy_write = ksz9477_phy_write16, + .adjust_link = ksz_adjust_link, .port_enable = ksz_enable_port, .port_disable = ksz_disable_port, .get_strings = ksz9477_get_strings,
@@ -1289,6 +1331,7 @@ static int ksz9477_switch_init(struct ksz_device *dev)if (!dev->ports)return -ENOMEM ;for (i =0 ; i < dev->mib_port_cnt; i++) { +mutex_init (&dev->ports[i].mib.cnt_mutex); dev->ports[i].mib.counters = devm_kzalloc(dev->dev, sizeof(u64) *
@@ -1310,7 +1353,12 @@ static void ksz9477_switch_exit(struct ksz_device *dev) .get_port_addr = ksz9477_get_port_addr, .cfg_port_member = ksz9477_cfg_port_member, .flush_dyn_mac_table = ksz9477_flush_dyn_mac_table, + .phy_setup = ksz9477_phy_setup, .port_setup = ksz9477_port_setup, + .r_mib_cnt = ksz9477_r_mib_cnt, + .r_mib_pkt = ksz9477_r_mib_pkt, + .freeze_mib = ksz9477_freeze_mib, + .port_init_cnt = ksz9477_port_init_cnt, .shutdown = ksz9477_reset_switch, .detect = ksz9477_switch_detect, .init = ksz9477_switch_init,
drivers/net/dsa/microchip/ksz9477_reg.h renamed from drivers/net/dsa/microchip/ksz_9477_reg.h +0 -0
drivers/net/dsa/microchip/ksz_common.c +122 -0
152 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_common.h +4 -0
@@ -21,12 +21,16 @@#define __KSZ_COMMON_Hvoid ksz_update_port_member (struct ksz_device *dev,int port); +void ksz_init_mib_timer (struct ksz_device *dev);/* Common DSA access functions */ int ksz_phy_read16 (struct dsa_switch *ds,int addr,int reg);int ksz_phy_write16 (struct dsa_switch *ds,int addr,int reg,u16 val); +void ksz_adjust_link (struct dsa_switch *ds,int port, +struct phy_device *phydev);int ksz_sset_count (struct dsa_switch *ds); +void ksz_get_ethtool_stats (struct dsa_switch *ds,int port,uint64_t *buf);int ksz_port_bridge_join (struct dsa_switch *ds,int port,struct net_device *br); void ksz_port_bridge_leave(struct dsa_switch *ds, int port,
drivers/net/dsa/microchip/ksz_priv.h +4 -4
@@ -26,8 +26,6 @@#include <linux/etherdevice.h> #include <net/dsa.h> -#include "ksz_9477_reg.h" -struct ksz_io_ops ;struct vlan_table {
@@ -35,6 +33,7 @@ struct vlan_table { };struct ksz_port_mib { +struct mutex cnt_mutex;/* structure access */ u8 cnt_ptr;u64 *counters; };
@@ -92,8 +91,6 @@ struct ksz_device {struct vlan_table *vlan_cache; -u64 mib_value[TOTAL_SWITCH_COUNTER_NUM ]; -u8 *txbuf;struct ksz_port *ports;
@@ -150,6 +147,8 @@ struct ksz_dev_ops {u32 (*get_port_addr)(int port,int offset);void (*cfg_port_member)(struct ksz_device *dev,int port,u8 member);void (*flush_dyn_mac_table)(struct ksz_device *dev,int port); +void (*phy_setup)(struct ksz_device *dev,int port, +struct phy_device *phy);void (*port_setup)(struct ksz_device *dev,int port,bool cpu_port);void (*r_phy)(struct ksz_device *dev,u16 phy,u16 reg,u16 *val);void (*w_phy)(struct ksz_device *dev,u16 phy,u16 reg,u16 val);
@@ -164,6 +163,7 @@ struct ksz_dev_ops { u64 *cnt);void (*r_mib_pkt)(struct ksz_device *dev,int port,u16 addr,u64 *dropped,u64 *cnt); +void (*freeze_mib)(struct ksz_device *dev,int port,bool freeze);void (*port_init_cnt)(struct ksz_device *dev,int port);int (*shutdown)(struct ksz_device *dev);int (*detect)(struct ksz_device *dev);
Signature · 1 line
1.9.1
RFC PATCH 7/7 Modify tag_ksz.c so that tail tag code can be used by other KSZ switch drivers
In reply to [email protected]From: Tristram Ha <[email protected]>
Modify tag_ksz.c so that tail tag code can be used by other KSZ switch drivers.
--- drivers/net/dsa/microchip/Kconfig | 2 +- drivers/net/dsa/microchip/ksz9477.c | 2 +- include/net/dsa.h | 2 +- net/dsa/Kconfig | 4 ++ net/dsa/dsa.c | 4 +- net/dsa/dsa_priv.h | 2 +- net/dsa/tag_ksz.c | 107 ++++++++++++++++++++++++++---------- 7 files changed, 88 insertions(+), 35 deletions(-)
drivers/net/dsa/microchip/Kconfig +1 -1
@@ -1,7 +1,7 @@ menuconfig MICROCHIP_KSZ9477 tristate "Microchip KSZ9477 series switch support" depends on NET_DSA - select NET_DSA_TAG_KSZ + select NET_DSA_TAG_KSZ9477 help This driver adds support for Microchip KSZ9477 switch chips.
drivers/net/dsa/microchip/ksz9477.c +1 -1
@@ -342,7 +342,7 @@ static void ksz9477_port_init_cnt(struct ksz_device *dev, int port)static enum dsa_tag_protocol ksz9477_get_tag_protocol (struct dsa_switch *ds) { -return DSA_TAG_PROTO_KSZ ; +return DSA_TAG_PROTO_KSZ9477 ; }static int ksz9477_phy_read16 (struct dsa_switch *ds,int addr,int reg)
include/net/dsa.h +1 -1
@@ -31,7 +31,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_BRCM ,DSA_TAG_PROTO_DSA ,DSA_TAG_PROTO_EDSA , -DSA_TAG_PROTO_KSZ , +DSA_TAG_PROTO_KSZ9477 ,DSA_TAG_PROTO_LAN9303 ,DSA_TAG_PROTO_MTK , DSA_TAG_PROTO_QCA,
net/dsa/Kconfig +4 -0
@@ -28,6 +28,10 @@ config NET_DSA_TAG_EDSA config NET_DSA_TAG_KSZ bool +config NET_DSA_TAG_KSZ9477 + bool + select NET_DSA_TAG_KSZ + config NET_DSA_TAG_LAN9303 bool
net/dsa/dsa.c +2 -2
@@ -49,8 +49,8 @@ static struct sk_buff *dsa_slave_notag_xmit(struct sk_buff *skb, #ifdef CONFIG_NET_DSA_TAG_EDSA [DSA_TAG_PROTO_EDSA ] = &edsa_netdev_ops, #endif -#ifdef CONFIG_NET_DSA_TAG_KSZ - [DSA_TAG_PROTO_KSZ ] = &ksz_netdev_ops, +#ifdef CONFIG_NET_DSA_TAG_KSZ9477 + [DSA_TAG_PROTO_KSZ9477 ] = &ksz9477_netdev_ops, #endif #ifdef CONFIG_NET_DSA_TAG_LAN9303 [DSA_TAG_PROTO_LAN9303] = &lan9303_netdev_ops,
net/dsa/dsa_priv.h +1 -1
@@ -183,7 +183,7 @@ int dsa_port_vlan_del(struct dsa_port *dp,extern const struct dsa_device_ops edsa_netdev_ops;/* tag_ksz.c */ -extern const struct dsa_device_ops ksz_netdev_ops; +extern const struct dsa_device_ops ksz9477_netdev_ops;/* tag_lan9303.c */ extern const struct dsa_device_ops lan9303_netdev_ops;
net/dsa/tag_ksz.c +78 -29
152 lines not on this page · raw message
Signature · 1 line
1.9.1
RE: [PATCH v1 RFC 1/7] Replace license with GPL
In reply to [email protected]From: [email protected]
Quoted 2 lines
Sent: 06 October 2017 21:33
Replace license with GPL.
Don't you need permission from all the people who have updated the files in order to make this change?
David
RE: [PATCH v1 RFC 1/7] Replace license with GPL
Quoted 8 lines
From: [email protected]
Quoted 2 lines
Sent: 06 October 2017 21:33
Replace license with GPL.Don't you need permission from all the people who have updated the files in order to make this change?
David
I am a little confused by your comment. The 4 original KSZ9477 DSA driver files were written by Woojung at Microchip Technology Inc. There was a complaint the "AS IS" license is not exactly GPL.
It should be submitted formally to net-next instead of a RFC, but it is probably pointless to do that when there is no code change.
I am hoping these drastic changes of KSZ9477 driver can be accepted so that the patches can be submitted formally to net-next.
Re: [PATCH v1 RFC 1/7] Replace license with GPL
Quoted 13 lines · On 10/09/2017 11:40 AM, [email protected] wrote:
Quoted 8 lines
From: [email protected]
Quoted 2 lines
Sent: 06 October 2017 21:33
Replace license with GPL.Don't you need permission from all the people who have updated the files in order to make this change?
David
I am a little confused by your comment. The 4 original KSZ9477 DSA driver files were written by Woojung at Microchip Technology Inc. There was a complaint the "AS IS" license is not exactly GPL.
Quoted 5 lines
It should be submitted formally to net-next instead of a RFC, but it is probably pointless to do that when there is no code change.
I am hoping these drastic changes of KSZ9477 driver can be accepted so that the patches can be submitted formally to net-next.
What David is saying is that you need to take into account every one who has been making changes to the Microchip driver, because anytime someones submits a patch that gets accepted, their "voice" now counts:
Fortunately, the list seems to be fairly limited:
git shortlog -sne drivers/net/dsa/microchip
5 Arkadi Sharshevsky <[email protected]>
1 Woojung Huh <[email protected]>
So seeking contributor approval for a license change should be fairly simple.
Signature · 1 line
Florian
Re: [PATCH v1 RFC 1/7] Replace license with GPL
In reply to [email protected]Quoted 5 lines · On Fri 2017-10-06 13:32:59, [email protected] wrote:
From: Tristram Ha <[email protected]>
Replace license with GPL.
Signed-off-by Tristram Ha <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v1 RFC 2/7] Clean up code according to patch check suggestions
In reply to [email protected]Quoted 5 lines · On Fri 2017-10-06 13:33:00, [email protected] wrote:
From: Tristram Ha <[email protected]>
Clean up code according to patch check suggestions.
Signed-off-by Tristram Ha <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v1 RFC 3/7] Rename some functions with ksz9477 prefix
In reply to [email protected]Quoted 6 lines · On Fri 2017-10-06 13:33:01, [email protected] wrote:
From: Tristram Ha <[email protected]>
Rename some functions with ksz9477 prefix to separate chip specific code from common code.
Signed-off-by Tristram Ha <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v1 RFC 4/7] Rename ksz_spi.c to ksz9477_spi.c
In reply to [email protected]Quoted 6 lines · On Fri 2017-10-06 13:33:02, [email protected] wrote:
From: Tristram Ha <[email protected]>
Rename
ksz_spi.ctoksz9477_spi.cand updateKconfigin preparation to add more KSZ switch drivers.Signed-off-by Tristram Ha <[email protected]>
This will ask people question they already answered, but I guess that's ok.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v1 RFC 5/7] Break KSZ9477 DSA driver into two files
In reply to [email protected]Quoted 9 lines · On Fri 2017-10-06 13:33:03, [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.Signed-off-by Tristram Ha <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v1 RFC 6/7] Add MIB counter reading support
In reply to [email protected]Hi!
Quoted 6 lines
From: Tristram Ha <[email protected]>
Add MIB counter reading support.
Renameksz_9477_reg.htoksz9477_reg.hfor consistency as the product name is always KSZ####.
Header fileksz_priv.hno longer contains any chip specific data.
Nothing obviously wrong here, but if you are doing another iteration, it would be nice to separate "Rename ksz_9477_reg.h to ksz9477_reg.h" from the code changes.
Best regards,
drivers/net/dsa/microchip/ksz9477.c static int ksz9477_reset_switch(struct ksz_device *dev) · line 296
Quoted 8 lines
drivers/net/dsa/microchip/ksz9477.c +8
-0+ timeout =1000 ; +do { +ksz_pread32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 , + &data); +usleep_range (1 ,10 ); +if (!(data &MIB_COUNTER_READ )) +break ; + }while (timeout-- >0 );
1000 iterations, 1usec each, so 1msec, but you allow up to 10 msec. Interesting.
drivers/net/dsa/microchip/ksz9477.c static int ksz9477_reset_switch(struct ksz_device *dev) · line 302
Quoted 5 lines
drivers/net/dsa/microchip/ksz9477.c +5
-0+/* failed to read MIB. get out of loop */ +if (!timeout) { +dev_dbg (dev->dev,"Failed to get MIB\n" ); +return ; + }
Are you sure this works? AFAICT "timeout" will underflow, so !timeout will not trigger.
Quoted 19 lines
drivers/net/dsa/microchip/ksz9477.c +0
-19-static void ksz_get_ethtool_stats (struct dsa_switch *ds,int port, -uint64_t *buf) -{ -struct ksz_device *dev = ds->priv; -int i; -u32 data; -int timeout; - -mutex_lock (&dev->stats_mutex); - -for (i =0 ; i <TOTAL_SWITCH_COUNTER_NUM ; i++) { - data =MIB_COUNTER_READ ; - data |= ((mib_names[i].index &0xFF ) <<MIB_COUNTER_INDEX_S ); -ksz_pwrite32 (dev, port,REG_PORT_MIB_CTRL_STAT__4 , data); - - timeout =1000 ; - do { - ksz_pread32(dev, port, REG_PORT_MIB_CTRL_STAT__4, - &data);
drivers/net/dsa/microchip/ksz9477.c static void ksz9477_get_strings(struct dsa_switch *ds, int port, uint8_t *buf) · line 381
Quoted 10 lines
drivers/net/dsa/microchip/ksz9477.c +0
-10-usleep_range (1 ,10 ); -if (!(data &MIB_COUNTER_READ )) -break ; - }while (timeout-- >0 ); - -/* failed to read MIB. get out of loop */ -if (!timeout) { -dev_dbg (dev->dev,"Failed to get MIB\n" ); -break ; - }
Hmm. Bug was there already...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v1 RFC 2/7] Clean up code according to patch check suggestions
In reply to [email protected]Quoted 5 lines · On 10/06/2017 01:33 PM, [email protected] wrote:
From: Tristram Ha <[email protected]>
Clean up code according to patch check suggestions.
Signed-off-by Tristram Ha <[email protected]>
Signature · 1 line
Florian
Re: [PATCH v1 RFC 3/7] Rename some functions with ksz9477 prefix
In reply to [email protected]Quoted 6 lines · On 10/06/2017 01:33 PM, [email protected] wrote:
From: Tristram Ha <[email protected]>
Rename some functions with ksz9477 prefix to separate chip specific code from common code.
Signed-off-by Tristram Ha <[email protected]>
Signature · 1 line
Florian
Re: [PATCH v1 RFC 4/7] Rename ksz_spi.c to ksz9477_spi.c
In reply to [email protected]Quoted 6 lines · On 10/06/2017 01:33 PM, [email protected] wrote:
From: Tristram Ha <[email protected]>
Rename
ksz_spi.ctoksz9477_spi.cand updateKconfigin preparation to add more KSZ switch drivers.Signed-off-by Tristram Ha <[email protected]>
Signature · 1 line
Florian
Quoted 11 lines · On 10/06/2017 01:32 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.
Most of this looks fine, and it is probably time to move away from the RFC state and do a formal patch submission with the Reviewed-by and Acked-by tags you just collected.
Can you also make sure you prefix your patches with: net: dsa: to be consistent with other submissions done to that subsystem, e.g:
net: dsa: microchip: Replace license with GPL
Thank you!
Quoted 47 lines
v1
- Each patch in the set is self-contained
- Use ksz9477 prefix to indicate KSZ9477 specific code
- Simplify MIB counter reading code
- Switch driver code is not accessed fromtag_ksz.cTristram Ha (7):
Replace license with GPL.
Clean up code according to patch check suggestions.
Rename some functions with ksz9477 prefix to separate chip specific
code from common code.
Renameksz_spi.ctoksz9477_spi.cand updateKconfigin preparation to
add more KSZ switch drivers.
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.
Add MIB counter reading support. Renameksz_9477_reg.hto
ksz9477_reg.hfor consistency as the product name is always KSZ####. Header fileksz_priv.hno longer contains any chip specific data.
Modifytag_ksz.cso that tail tag code can be used by other KSZ switch
drivers.drivers/net/dsa/microchip/Kconfig | 14 +- drivers/net/dsa/microchip/Makefile | 4 +- drivers/net/dsa/microchip/ksz9477.c | 1376 ++++++++++++++++++++ .../microchip/{ksz_9477_reg.h => ksz9477_reg.h} | 23 +- drivers/net/dsa/microchip/ksz9477_spi.c | 188 +++ drivers/net/dsa/microchip/ksz_common.c | 1210 ++++------------- drivers/net/dsa/microchip/ksz_common.h | 234 ++++ drivers/net/dsa/microchip/ksz_priv.h | 258 ++-- drivers/net/dsa/microchip/ksz_spi.c | 216 --- drivers/net/dsa/microchip/ksz_spi.h | 82 ++ include/net/dsa.h | 2 +- net/dsa/Kconfig | 4 + net/dsa/dsa.c | 4 +- net/dsa/dsa_priv.h | 2 +- net/dsa/tag_ksz.c | 107 +- 15 files changed, 2331 insertions(+), 1393 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
RE: [PATCH v1 RFC 1/7] Replace license with GPL
In reply to [email protected]Quoted 7 lines
Subject: [PATCH v1 RFC 1/7] Replace license with GPL
From: Tristram Ha <[email protected]>
Replace license with GPL.
Signed-off-by Tristram Ha <[email protected]>
Re: [PATCH v1 RFC 5/7] Break KSZ9477 DSA driver into two files
In reply to [email protected]Quoted 9 lines · On 10/06/2017 01:33 PM, [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.Signed-off-by Tristram Ha <[email protected]>
Signature · 1 line
Florian
Re: [PATCH v1 RFC 6/7] Add MIB counter reading support
In reply to [email protected]Quoted 6 lines · On 10/06/2017 01:33 PM, [email protected] wrote:
From: Tristram Ha <[email protected]>
Add MIB counter reading support.
Renameksz_9477_reg.htoksz9477_reg.hfor consistency as the product name is always KSZ####.
Header fileksz_priv.hno longer contains any chip specific data.
You should probably explain in the commit message that you are adding a timer that reads counters every 30 seconds to avoid overflows, as this is a pretty important piece of information.
drivers/net/dsa/microchip/ksz9477.c static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port, · line 1017
Quoted 10 lines
drivers/net/dsa/microchip/ksz9477.c +10
-0+static void ksz9477_phy_setup (struct ksz_device *dev,int port, +struct phy_device *phy) +{ +if (port < dev->phy_port_cnt) { +/* SUPPORTED_Asym_Pause and SUPPORTED_Pause can be removed to +* disable flow control when rate limiting is used. +*/ + phy->advertising = phy->supported; + } +}
This appears to be an unrelated change here that you would want to put in a separate patch.
Quoted 88 lines
drivers/net/dsa/microchip/ksz9477.c +10
-0+static void ksz9477_port_setup (struct ksz_device *dev,int port,bool cpu_port) {u8 data8;@@ -1159,6 +1198,8 @@ static int ksz9477_setup(struct dsa_switch *ds)/* start switch */ ksz_cfg (dev,REG_SW_OPERATION ,SW_START , true); +ksz_init_mib_timer (dev); +return 0 ; }@@ -1168,6 +1209,7 @@ static int ksz9477_setup(struct dsa_switch *ds) .set_addr = ksz9477_set_addr, .phy_read = ksz9477_phy_read16, .phy_write = ksz9477_phy_write16, + .adjust_link = ksz_adjust_link, .port_enable = ksz_enable_port, .port_disable = ksz_disable_port, .get_strings = ksz9477_get_strings,@@ -1289,6 +1331,7 @@ static int ksz9477_switch_init(struct ksz_device *dev)if (!dev->ports)return -ENOMEM ;for (i =0 ; i < dev->mib_port_cnt; i++) { +mutex_init (&dev->ports[i].mib.cnt_mutex); dev->ports[i].mib.counters = devm_kzalloc(dev->dev, sizeof(u64) *@@ -1310,7 +1353,12 @@ static void ksz9477_switch_exit(struct ksz_device *dev) .get_port_addr = ksz9477_get_port_addr, .cfg_port_member = ksz9477_cfg_port_member, .flush_dyn_mac_table = ksz9477_flush_dyn_mac_table, + .phy_setup = ksz9477_phy_setup, .port_setup = ksz9477_port_setup, + .r_mib_cnt = ksz9477_r_mib_cnt, + .r_mib_pkt = ksz9477_r_mib_pkt, + .freeze_mib = ksz9477_freeze_mib, + .port_init_cnt = ksz9477_port_init_cnt, .shutdown = ksz9477_reset_switch, .detect = ksz9477_switch_detect, .init = ksz9477_switch_init,drivers/net/dsa/microchip/ksz9477_reg.h renamed from drivers/net/dsa/microchip/ksz_9477_reg.h +0
-0drivers/net/dsa/microchip/ksz_common.c +34
-0@@ -50,6 +50,81 @@ void ksz_update_port_member(struct ksz_device *dev, int port) } } +static void port_r_cnt (struct ksz_device *dev,int port) +{ +struct ksz_port_mib *mib = &dev->ports[port].mib; +u64 *dropped; + +/* Some ports may not have MIB counters before SWITCH_COUNTER_NUM. */ +while (mib->cnt_ptr < dev->reg_mib_cnt) { + dev->dev_ops->r_mib_cnt (dev, port, mib->cnt_ptr, + &mib->counters[mib->cnt_ptr]); + ++mib->cnt_ptr; + } + +/* last one in storage */ + dropped = &mib->counters[dev->mib_cnt]; + +/* Some ports may not have MIB counters after SWITCH_COUNTER_NUM. */ +while (mib->cnt_ptr < dev->mib_cnt) { + dev->dev_ops->r_mib_pkt (dev, port, mib->cnt_ptr, + dropped, &mib->counters[mib->cnt_ptr]); + ++mib->cnt_ptr; + } + mib->cnt_ptr =0 ; +} + +static void ksz_mib_read_work (struct work_struct *work) +{ +struct ksz_device *dev = + container_of(work, struct ksz_device, mib_read); +struct ksz_port *p; +struct ksz_port_mib *mib; +int i; + +for (i =0 ; i < dev->mib_port_cnt; i++) { + p = &dev->ports[i];
drivers/net/dsa/microchip/ksz_common.c void ksz_update_port_member(struct ksz_device *dev, int port) · line 96
Quoted 10 lines
drivers/net/dsa/microchip/ksz_common.c +10
-0+if (!p->on) +continue ; + mib = &p->mib; +mutex_lock (&mib->cnt_mutex); + +/* read only dropped counters when link is not up */ +if (p->link_down) + p->link_down =0 ; +else if (!p->link_up) + mib->cnt_ptr = dev->reg_mib_cnt;
Can't you just check the ports' PHY device here instead of caching that (which can get out of sync)?
Quoted 8 lines
drivers/net/dsa/microchip/ksz_common.c +8
-0+void ksz_adjust_link (struct dsa_switch *ds,int port, +struct phy_device *phydev) +{ +struct ksz_device *dev = ds->priv; +struct ksz_port *p = &dev->ports[port]; + +if (phydev->link) { + p->speed = phydev->speed;
drivers/net/dsa/microchip/ksz_common.c int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val) · line 164
Quoted 10 lines
drivers/net/dsa/microchip/ksz_common.c +10
-0+ p->duplex = phydev->duplex; + p->flow_ctrl = phydev->pause; + p->link_up =1 ; + dev->live_ports |= (1 << port) & dev->on_ports; + }else if (p->link_up) { + p->link_up =0 ; + p->link_down =1 ; + dev->live_ports &= ~(1 << port); + } +}
It would have been nice to explain why this is needed in the commit message. dev->live_ports is read-only it seems?
Signature · 1 line
Florian
Re: [PATCH v1 RFC 7/7] Modify tag_ksz.c so that tail tag code can be used by other KSZ switch drivers
In reply to [email protected]Hi!
Quoted 1 line
+#define
KSZ_INGRESS_TAG_LEN1
This define is now (or should be) unused, so you can delete it, no?
Quoted 1 line
_#define
KSZ_EGRESS_TAG_LEN1
And I'd delete this define, too. Having constant for something that's variable is quite confusing :-).
Plus you are really doing too much inside single patch.
Quoted 25 lines
+ * For Egress (KSZ9477 -> Host), 1 byte is added before FCS.
+ * ---------------------------------------------------------------------------
+ * DA(6bytes)|SA(6bytes)|....|Data(nbytes)|tag0(1byte)|FCS(4bytes)
+ * ---------------------------------------------------------------------------
+ * tag0 : zero-based value represents port
+ * (eg, 0x00=port1, 0x02=port3, 0x06=port7)
+ */net/dsa/tag_ksz.c +18
-0+ +#define KSZ9477_INGRESS_TAG_LEN 2 +#define KSZ9477_PTP_TAG_LEN 4 +#define KSZ9477_PTP_TAG_INDICATION 0x80 + +#define KSZ9477_TAIL_TAG_OVERRIDE BIT(9) +#define KSZ9477_TAIL_TAG_LOOKUP BIT(10) + +static int ksz9477_get_tag (u8 *tag,int *port) +{ +int len =KSZ_EGRESS_TAG_LEN ; + +/* Extra 4-bytes PTP timestamp */ +if (tag[0 ] &KSZ9477_PTP_TAG_INDICATION ) + len +=KSZ9477_PTP_TAG_LEN ; + *port = tag[0 ] &7 ; +return len; +}
net/dsa/tag_ksz.c static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev) · line 134
Quoted 10 lines
net/dsa/tag_ksz.c +10
-0+ +static void ksz9477_set_tag (void *ptr,u8 *addr,int p) +{ +u16 *tag = (u16 *)ptr; + + *tag =1 << p; +if (!memcmp (addr, special_mult_addr,ETH_ALEN )) + *tag |=KSZ9477_TAIL_TAG_OVERRIDE ; + *tag =cpu_to_be16 (*tag); +}
These are new features that were not there before, right?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Andrew Lunn
maintainerRe: [PATCH v1 RFC 1/7] Replace license with GPL
In reply to David LaightQuoted 6 lines · David Laight
From: [email protected]
Quoted 2 lines
Sent: 06 October 2017 21:33
Replace license with GPL.Don't you need permission from all the people who have updated the files in order to make this change?
Hi David
Interesting question.
ksz_9477_reg.h and ksz_spi.c are not a problem, since Woojung Huh is the only contributor.
ksz_common.c has a MODULE_LICENSE("GPL") so indicating it probably was intended to the GPL.
However, getting an acked-by from Arkadi Sharshevsky <[email protected]> would be good.
Andrew
Re: [PATCH v1 RFC 2/7] Clean up code according to patch check suggestions
In reply to [email protected]Quoted 5 lines · On Fri, Oct 06, 2017 at 01:33:00PM -0700, [email protected] wrote:
From: Tristram Ha <[email protected]>
Clean up code according to patch check suggestions.
Signed-off-by Tristram Ha <[email protected]>
Andrew
Re: [PATCH v1 RFC 3/7] Rename some functions with ksz9477 prefix
In reply to [email protected]Quoted 6 lines · On Fri, Oct 06, 2017 at 01:33:01PM -0700, [email protected] wrote:
From: Tristram Ha <[email protected]>
Rename some functions with ksz9477 prefix to separate chip specific code from common code.
Signed-off-by Tristram Ha <[email protected]>
Andrew
Re: [PATCH v1 RFC 4/7] Rename ksz_spi.c to ksz9477_spi.c
In reply to [email protected]Quoted 6 lines · On Fri, Oct 06, 2017 at 01:33:02PM -0700, [email protected] wrote:
From: Tristram Ha <[email protected]>
Rename
ksz_spi.ctoksz9477_spi.cand updateKconfigin preparation to add more KSZ switch drivers.Signed-off-by Tristram Ha <[email protected]>
Andrew
Re: [PATCH v1 RFC 5/7] Break KSZ9477 DSA driver into two files
In reply to [email protected]Quoted 84 lines
drivers/net/dsa/microchip/ksz9477.c new file +78
-0@@ -0,0 +1,1328 @@ +/* +* Microchip KSZ9477 switch driver main logic +* +* Copyright (C) 2017 Microchip Technology Inc. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <linux/delay.h> +#include <linux/export.h> +#include <linux/gpio.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/platform_data/microchip-ksz.h> +#include <linux/phy.h> +#include <linux/etherdevice.h> +#include <linux/if_bridge.h> +#include <net/dsa.h> +#include <net/switchdev.h> + +#include "ksz_priv.h" +#include "ksz_common.h" +#include "ksz_9477_reg.h" + +static const struct { +int index; +char string[ETH_GSTRING_LEN ]; +} mib_names[TOTAL_SWITCH_COUNTER_NUM ] = { + {0x00 ,"rx_hi" }, + {0x01 ,"rx_undersize" }, + {0x02 ,"rx_fragments" }, + {0x03 ,"rx_oversize" }, + {0x04 ,"rx_jabbers" }, + {0x05 ,"rx_symbol_err" }, + {0x06 ,"rx_crc_err" }, + {0x07 ,"rx_align_err" }, + {0x08 ,"rx_mac_ctrl" }, + {0x09 ,"rx_pause" }, + {0x0A ,"rx_bcast" }, + {0x0B ,"rx_mcast" }, + {0x0C ,"rx_ucast" }, + {0x0D ,"rx_64_or_less" }, + {0x0E ,"rx_65_127" }, + {0x0F ,"rx_128_255" }, + {0x10 ,"rx_256_511" }, + {0x11 ,"rx_512_1023" }, + {0x12 ,"rx_1024_1522" }, + {0x13 ,"rx_1523_2000" }, + {0x14 ,"rx_2001" }, + {0x15 ,"tx_hi" }, + {0x16 ,"tx_late_col" }, + {0x17 ,"tx_pause" }, + {0x18 ,"tx_bcast" }, + {0x19 ,"tx_mcast" }, + {0x1A ,"tx_ucast" }, + {0x1B ,"tx_deferred" }, + {0x1C ,"tx_total_col" }, + {0x1D ,"tx_exc_col" }, + {0x1E ,"tx_single_col" }, + {0x1F ,"tx_mult_col" }, + {0x80 ,"rx_total" }, + {0x81 ,"tx_total" }, + {0x82 ,"rx_discards" }, + {0x83 ,"tx_discards" }, +}; + +static void ksz_cfg32 (struct ksz_device *dev,u32 addr,u32 bits,bool set)
drivers/net/dsa/microchip/ksz9477.c line 88
Quoted 10 lines
drivers/net/dsa/microchip/ksz9477.c new file +10
-0+{ +u32 data; + +ksz_read32 (dev, addr, &data); +if (set) + data |= bits; +else + data &= ~bits; +ksz_write32 (dev, addr, data); +}
In a follow up patch, it would be good to fixup the naming. All functions should use the ksz9477_ prefix.
But this is O.K. for now.
Andrew
Andrew Lunn
maintainerRe: [PATCH v1 RFC 6/7] Add MIB counter reading support
In reply to [email protected]drivers/net/dsa/microchip/ksz9477.c static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port, · line 1018
Quoted 11 lines
drivers/net/dsa/microchip/ksz9477.c +11
-0+static void ksz9477_phy_setup (struct ksz_device *dev,int port, +struct phy_device *phy) +{ +if (port < dev->phy_port_cnt) { +/* SUPPORTED_Asym_Pause and SUPPORTED_Pause can be removed to +* disable flow control when rate limiting is used. +*/ + phy->advertising = phy->supported; + } +} +
This has nothing to do with MIBs. It does not belong in this patch.
Quoted 13 lines
static void
ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port){drivers/net/dsa/microchip/ksz9477.c +2
-0u8 data8;@@ -1159,6 +1198,8 @@ static int ksz9477_setup(struct dsa_switch *ds)/* start switch */ ksz_cfg (dev,REG_SW_OPERATION ,SW_START , true); +ksz_init_mib_timer (dev); +return 0 ; }
drivers/net/dsa/microchip/ksz9477.c static int ksz9477_setup(struct dsa_switch *ds) · line 1212
Quoted 4 lines
drivers/net/dsa/microchip/ksz9477.c +1
-0@@ -1168,6 +1209,7 @@ static int ksz9477_setup(struct dsa_switch *ds) .set_addr = ksz9477_set_addr, .phy_read = ksz9477_phy_read16, .phy_write = ksz9477_phy_write16, + .adjust_link = ksz_adjust_link,
Please move the adjust_link changes into a separate patch.
I need to come back at look at the mutex's and the freeze code. It is not obviously correct, and i don't have the time at the moment.
Andrew
Andrew Lunn
maintainerRe: [PATCH v1 RFC 7/7] Modify tag_ksz.c so that tail tag code can be used by other KSZ switch drivers
In reply to [email protected]Quoted 4 lines · On Fri, Oct 06, 2017 at 01:33:05PM -0700, [email protected] wrote:
From: Tristram Ha <[email protected]>
Modify
tag_ksz.cso that tail tag code can be used by other KSZ switch drivers.
There is multiple things going on in this patch. Please split the special_mult_addr change into a separate patch, with an explanation why it is needed. Same for the PTP indication.
It is always better to have lots of small patches, one logical change per patch.
Andrew
RE: [PATCH v1 RFC 7/7] Modify tag_ksz.c so that tail tag code can be used by other KSZ switch drivers
In reply to Pavel MachekQuoted 21 lines
Quoted 21 lines
net/dsa/tag_ksz.c +21
-0+#define KSZ9477_INGRESS_TAG_LEN 2 +#define KSZ9477_PTP_TAG_LEN 4 +#define KSZ9477_PTP_TAG_INDICATION 0x80 + +#define KSZ9477_TAIL_TAG_OVERRIDE BIT(9) +#define KSZ9477_TAIL_TAG_LOOKUP BIT(10) + +static int ksz9477_get_tag (u8 *tag,int *port) +{ +int len =KSZ_EGRESS_TAG_LEN ; + +/* Extra 4-bytes PTP timestamp */ +if (tag[0 ] &KSZ9477_PTP_TAG_INDICATION ) + len +=KSZ9477_PTP_TAG_LEN ; + *port = tag[0 ] &7 ; +return len; +} + +static void ksz9477_set_tag (void *ptr,u8 *addr,int p) +{ +u16 *tag = (u16 *)ptr;
Quoted 8 lines
net/dsa/tag_ksz.c static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev) · line 134
Quoted 6 lines
net/dsa/tag_ksz.c +6
-0+ + *tag =1 << p; +if (!memcmp (addr, special_mult_addr,ETH_ALEN )) + *tag |=KSZ9477_TAIL_TAG_OVERRIDE ; + *tag =cpu_to_be16 (*tag); +}These are new features that were not there before, right?
Although it is the correct procedure, they will be removed until this tail tag code has access to the main switch driver.