Skip to contentSkip to conversation

net: dsa: microchip: Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers

PATCH Superseded [email protected] 4 participants 17 messages Dec 6, 2017 – Oct 20, 2018

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 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.

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 (8):
Replace license with GPL.
Clean up code according to patch check suggestions. Initialize mutex before use.
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.
Prepare PHY for proper advertisement and get link status for the port. Rename ksz_9477_reg.h to ksz9477_reg.h for consistency as the product
name is always KSZ####.

 drivers/net/dsa/microchip/Kconfig                  |   12 +-
 drivers/net/dsa/microchip/Makefile                 |    4 +-
 drivers/net/dsa/microchip/ksz9477.c                | 1331 ++++++++++++++++++++
 .../microchip/{ksz_9477_reg.h => ksz9477_reg.h}    |   23 +-
 drivers/net/dsa/microchip/ksz9477_spi.c            |  188 +++
 drivers/net/dsa/microchip/ksz_common.c             | 1176 +++--------------
 drivers/net/dsa/microchip/ksz_common.h             |  229 ++++
 drivers/net/dsa/microchip/ksz_priv.h               |  256 ++--
 drivers/net/dsa/microchip/ksz_spi.c                |  216 ----
 drivers/net/dsa/microchip/ksz_spi.h                |   82 ++
 10 files changed, 2122 insertions(+), 1395 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
1.9.1
#1 lore raw

PATCH v2 1/8 net: dsa: microchip: 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
index 6aa6752..26a0e4b 100644
@@ -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
index 663b0d5..d662a9a 100644
@@ -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
index 2a98dbd..d461468 100644
@@ -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
index c519469..d0d6920 100644
@@ -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
#2 lore raw

PATCH v2 2/8 net: dsa: microchip: 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
index d662a9a..435c463 100644
@@ -895,9 +895,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;
 			}
@@ -968,9 +968,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
#3 lore raw

PATCH v2 3/8 net: dsa: microchip: Initialize mutex before use

In reply to [email protected]

From: Tristram Ha <[email protected]>

Initialize mutex before use.

---
 drivers/net/dsa/microchip/ksz_common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/dsa/microchip/ksz_common.c +3 -1
index 435c463..e656615 100644
@@ -1102,7 +1102,6 @@ static int ksz_switch_init(struct ksz_device *dev)
 {
 	int i;
 
-	mutex_init(&dev->reg_mutex);
 	mutex_init(&dev->stats_mutex);
 	mutex_init(&dev->alu_mutex);
 	mutex_init(&dev->vlan_mutex);
@@ -1191,6 +1190,9 @@ int ksz_switch_register(struct ksz_device *dev)
 	if (dev->pdata)
 		dev->chip_id = dev->pdata->chip_id;
 
+	/* mutex is used in next function call. */
+	mutex_init(&dev->reg_mutex);
+
 	if (ksz_switch_detect(dev))
 		return -EINVAL;
 
Signature · 1 line
1.9.1
#5 lore raw

PATCH v2 4/8 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 | 114 +++++++++++++++++----------------
 1 file changed, 58 insertions(+), 56 deletions(-)
drivers/net/dsa/microchip/ksz_common.c +58 -56
index e656615..009ee5f 100644
@@ -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,13 +394,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;
@@ -411,7 +410,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;
 
@@ -426,7 +426,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;
 }
@@ -445,7 +445,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;
 
@@ -495,7 +495,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;
@@ -540,7 +541,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,8 +569,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];
@@ -601,8 +603,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;
@@ -657,8 +659,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];
@@ -714,8 +716,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];
@@ -804,8 +806,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;
@@ -863,8 +865,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];
@@ -933,8 +935,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];
@@ -1010,9 +1012,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;
 
@@ -1032,8 +1034,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;
@@ -1051,29 +1053,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 {
@@ -1086,7 +1088,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",
@@ -1098,7 +1100,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;
 
@@ -1108,8 +1110,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;
@@ -1196,7 +1198,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
#6 lore raw

PATCH v2 5/8 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
index a8b8f59..5a8660d 100644
@@ -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
index ed335e2..5b6325b 100644
@@ -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
similarity index 100%
rename from drivers/net/dsa/microchip/ksz_spi.c
rename to drivers/net/dsa/microchip/ksz9477_spi.c
Signature · 1 line
1.9.1
#7 lore raw

PATCH v2 6/8 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/Makefile      |    2 +-
 drivers/net/dsa/microchip/ksz9477.c     | 1318 +++++++++++++++++++++++++++++++
 drivers/net/dsa/microchip/ksz9477_spi.c |  143 ++--
 drivers/net/dsa/microchip/ksz_common.c  | 1139 +++-----------------------
 drivers/net/dsa/microchip/ksz_common.h  |  227 ++++++
 drivers/net/dsa/microchip/ksz_priv.h    |  229 +++---
 drivers/net/dsa/microchip/ksz_spi.h     |   82 ++
 7 files changed, 1911 insertions(+), 1229 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
index 5b6325b..13dd8f0 100644
@@ -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 +1318 -0

1,318 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 +126 -1013

1,285 lines not on this page · raw message

drivers/net/dsa/microchip/ksz_common.h new file +227 -0

167 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.

#8 lore raw

PATCH v2 7/8 net: dsa: microchip: Prepare PHY for proper advertisement

In reply to [email protected]

From: Tristram Ha <[email protected]>

Prepare PHY for proper advertisement and get link status for the port.

---
 drivers/net/dsa/microchip/ksz9477.c    | 13 +++++++++++++
 drivers/net/dsa/microchip/ksz_common.c | 20 ++++++++++++++++++++
 drivers/net/dsa/microchip/ksz_common.h |  2 ++
 drivers/net/dsa/microchip/ksz_priv.h   |  2 ++
 4 files changed, 37 insertions(+)
drivers/net/dsa/microchip/ksz9477.c +13 -0
index 2c407bd..537342a 100644
@@ -978,6 +978,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 +1170,7 @@ static int ksz9477_setup(struct dsa_switch *ds)
 	.setup			= ksz9477_setup,
 	.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,
@@ -1300,6 +1312,7 @@ 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,
 	.shutdown = ksz9477_reset_switch,
 	.detect = ksz9477_switch_detect,
drivers/net/dsa/microchip/ksz_common.c +20 -0
index b535544..624abdd 100644
@@ -69,6 +69,25 @@ int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val)
 	return 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;
+		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);
+	}
+}
+
 int ksz_sset_count(struct dsa_switch *ds)
 {
 	struct ksz_device *dev = ds->priv;
@@ -235,6 +254,7 @@ int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
 
 	/* setup slave port */
 	dev->dev_ops->port_setup(dev, port, false);
+	dev->dev_ops->phy_setup(dev, port, phy);
 
 	/* port_stp_state_set() will be called after to enable the port so
 	 * there is no need to do anything.
drivers/net/dsa/microchip/ksz_common.h +2 -0
index dd2a468..599d4e5 100644
@@ -26,6 +26,8 @@
 
 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);
 int ksz_port_bridge_join(struct dsa_switch *ds, int port,
 			 struct net_device *br);
drivers/net/dsa/microchip/ksz_priv.h +2 -0
index 4126749..d92a7c1 100644
@@ -150,6 +150,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);
Signature · 1 line
1.9.1
maintainer
#9 lore raw

Re: [PATCH v2 net-next 7/8] net: dsa: microchip: Prepare PHY for proper advertisement

Hi Tristram

drivers/net/dsa/microchip/ksz9477.c static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port, · line 989

Quoted 9 lines
drivers/net/dsa/microchip/ksz9477.c +9 -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 looks a bit odd. phy_probe() does the same:

       /* Start out supporting everything. Eventually,
         * a controller will attach, and may modify one
         * or both of these values
         */
        phydev->supported = phydrv->features;
        of_set_phy_supported(phydev);
        phydev->advertising = phydev->supported;

You don't modify anything here, so i don't see why it is needed.

Quoted 7 lines
drivers/net/dsa/microchip/ksz_common.c +7 -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) {

drivers/net/dsa/microchip/ksz_common.c int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val) · line 88

Quoted 10 lines
drivers/net/dsa/microchip/ksz_common.c +10 -0
+		p->speed = phydev->speed;
+		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);
+	}

The link_down looks odd. If you are setting link_up to 1, should link_down also be set to 0? Can it be both up and down at the same time?

Andrew

#10 lore raw

RE: [PATCH v2 net-next 7/8] net: dsa: microchip: Prepare PHY for proper advertisement

Quoted 21 lines

drivers/net/dsa/microchip/ksz9477.c static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port,

Quoted 5 lines
drivers/net/dsa/microchip/ksz9477.c +5 -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

drivers/net/dsa/microchip/ksz9477.c static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port, · line 989

Quoted 4 lines
drivers/net/dsa/microchip/ksz9477.c +4 -0
+		 * disable flow control when rate limiting is used.
+		 */
+		phy->advertising = phy->supported;
+	}

This looks a bit odd. phy_probe() does the same:

       /* Start out supporting everything. Eventually,
         * a controller will attach, and may modify one
         * or both of these values
         */
        phydev->supported = phydrv->features;
        of_set_phy_supported(phydev);
        phydev->advertising = phydev->supported;
Quoted 2 lines

You don't modify anything here, so i don't see why it is needed.

In my case I always see the value of advertising is 0x02ff, while that of supported is 0x62ff. The Cadence MAC I use does not support flow control, so maybe the advertising value is stripped of that.

If I do not do anything flow control will not be enabled for the ports. A device connected at 1000 Mbit and another connected at 100 Mbit will have dropped packet issue if the switch does not do anything else to regulate traffic.

For other switches that do not really support Asymmetric Pause it has to be explicitly removed.

Quoted 13 lines
Quoted 13 lines
drivers/net/dsa/microchip/ksz_common.c +13 -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;
+		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) {
Quoted 8 lines

drivers/net/dsa/microchip/ksz_common.c int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val) · line 88

Quoted 4 lines
drivers/net/dsa/microchip/ksz_common.c +4 -0
+		p->link_up = 0;
+		p->link_down = 1;
+		dev->live_ports &= ~(1 << port);
+	}

The link_down looks odd. If you are setting link_up to 1, should link_down also be set to 0? Can it be both up and down at the same time?

These variables are used internally. link_up is an indication of the link; link_down means the link is just dropped. It is used for MIB counter reading. When the link is down most of the MIB counters will not be updated, so it is a waste of time to read them. They still are read at least one more time to pick up any updated counters.

#11 lore raw

Re: [PATCH v2 net-next 7/8] net: dsa: microchip: Prepare PHY for proper advertisement

Quoted 21 lines · On 12/06/2017 01:55 PM, [email protected] wrote:
Quoted 21 lines

drivers/net/dsa/microchip/ksz9477.c static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port,

Quoted 5 lines
drivers/net/dsa/microchip/ksz9477.c +5 -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

drivers/net/dsa/microchip/ksz9477.c static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port, · line 989

Quoted 4 lines
drivers/net/dsa/microchip/ksz9477.c +4 -0
+		 * disable flow control when rate limiting is used.
+		 */
+		phy->advertising = phy->supported;
+	}

This looks a bit odd. phy_probe() does the same:

       /* Start out supporting everything. Eventually,
         * a controller will attach, and may modify one
         * or both of these values
         */
        phydev->supported = phydrv->features;
        of_set_phy_supported(phydev);
        phydev->advertising = phydev->supported;
Quoted 6 lines
Quoted 2 lines

You don't modify anything here, so i don't see why it is needed.

In my case I always see the value of advertising is 0x02ff, while that of supported is 0x62ff. The Cadence MAC I use does not support flow control, so maybe the advertising value is stripped of that.

Pause is something that is auto-negotiated, if you don't somehow clear it, then the Ethernet MAC on the other side can start sending you pause frames, and if you don't respond back, then there are flow control problems.

Quoted 2 lines

If I do not do anything flow control will not be enabled for the ports.

Indeed, but likely there are also switch registers that need to be programmed such that the pseudo Ethernet MAC in the switch properly manages Pause frames.

Quoted 6 lines

A device connected at 1000 Mbit and another connected at 100 Mbit will have dropped packet issue if the switch does not do anything else to regulate traffic.

For other switches that do not really support Asymmetric Pause it has to be explicitly removed.

If Pause or Asym Pause is not meant to be used/supported for particular switches, then somehow you need to clear those bits and avoid advertising them, and most likely you should do that in your ds->ops->port_enable callback to make this work before phy_start() runs.

Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
drivers/net/dsa/microchip/ksz_common.c +13 -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;
+		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) {
Quoted 8 lines

drivers/net/dsa/microchip/ksz_common.c int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val) · line 88

Quoted 4 lines
drivers/net/dsa/microchip/ksz_common.c +4 -0
+		p->link_up = 0;
+		p->link_down = 1;
+		dev->live_ports &= ~(1 << port);
+	}

The link_down looks odd. If you are setting link_up to 1, should link_down also be set to 0? Can it be both up and down at the same time?

Quoted 5 lines

These variables are used internally. link_up is an indication of the link; link_down means the link is just dropped. It is used for MIB counter reading. When the link is down most of the MIB counters will not be updated, so it is a waste of time to read them. They still are read at least one more time to pick up any updated counters.

I suppose the question is, why is it okay for those not to be symmetrical (i.e: not set link_down = 0 when UP)? And considering that you should have either regular or fixed PHYs for each of your ports, including the CPU port, why not use phydev->link everywhere as an indication of whether a given port's link is up or down?

#12 lore raw

PATCH v2 8/8 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
index 537342a..801117a 100644
@@ -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;
drivers/net/dsa/microchip/ksz9477_reg.h renamed from drivers/net/dsa/microchip/ksz_9477_reg.h +0 -0
similarity index 100%
rename from drivers/net/dsa/microchip/ksz_9477_reg.h
rename to drivers/net/dsa/microchip/ksz9477_reg.h
drivers/net/dsa/microchip/ksz_priv.h +1 -1
index d92a7c1..bfe9066 100644
@@ -26,7 +26,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
Reviewed-by on v2 8/8
#13 lore raw

Re: [PATCH v2 net-next 8/8] net: dsa: microchip: Rename ksz_9477_reg.h to ksz9477_reg.h

Quoted 8 lines · On Tue 2017-12-05 17:46:38, [email protected] wrote:

From: Tristram Ha <[email protected]>

Rename ksz_9477_reg.h to ksz9477_reg.h for consistency as the product name is always KSZ####.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#14 lore raw
In reply to [email protected]
Quoted 11 lines · On 12/05/2017 05:46 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.c so that it can handle many tail tag formats used by different KSZ switch drivers.

Quoted 8 lines

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.

Is something gating this series from getting included? It's been nearly 8 months now and this has not been include nor resubmitted, any plans to rebase that patch series and work towards inclusion in net-next when it opens back again?

Thank you!

Quoted 43 lines

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 (8):
Replace license with GPL.
Clean up code according to patch check suggestions. Initialize mutex before use.
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.
Prepare PHY for proper advertisement and get link status for the port. Rename ksz_9477_reg.h to ksz9477_reg.h for consistency as the product
name is always KSZ####.

 drivers/net/dsa/microchip/Kconfig                  |   12 +-
 drivers/net/dsa/microchip/Makefile                 |    4 +-
 drivers/net/dsa/microchip/ksz9477.c                | 1331 ++++++++++++++++++++
 .../microchip/{ksz_9477_reg.h => ksz9477_reg.h}    |   23 +-
 drivers/net/dsa/microchip/ksz9477_spi.c            |  188 +++
 drivers/net/dsa/microchip/ksz_common.c             | 1176 +++--------------
 drivers/net/dsa/microchip/ksz_common.h             |  229 ++++
 drivers/net/dsa/microchip/ksz_priv.h               |  256 ++--
 drivers/net/dsa/microchip/ksz_spi.c                |  216 ----
 drivers/net/dsa/microchip/ksz_spi.h                |   82 ++
 10 files changed, 2122 insertions(+), 1395 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
#15 lore raw
Quoted 32 lines

-----Original Message-----
From: Florian Fainelli <[email protected]>
Sent: Wednesday, August 15, 2018 5:29 PM
To: Tristram Ha - C24268 <[email protected]>; Andrew Lunn <[email protected]>; Pavel Machek <[email protected]>; Ruediger Schmitt <[email protected]>
Cc: Arkadi Sharshevsky <[email protected]>; UNGLinuxDriver <[email protected]>; [email protected]
Subject: Re: [PATCH v2 net-next 0/8] net: dsa: microchip: Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers

Quoted 11 lines · On 12/05/2017 05:46 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.c so that it can handle many tail tag formats used by different KSZ switch drivers.

Quoted 8 lines

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.

Quoted 6 lines

Is something gating this series from getting included? It's been nearly 8 months now and this has not been include nor resubmitted, any plans to rebase that patch series and work towards inclusion in net-next when it opens back again?

Thank you!

Sorry for the long delay. I will restart my kernel submission effort next month after finishing the work on current development project.

#16 lore raw
Quoted 37 lines · On 08/16/2018 02:34 PM, [email protected] wrote:
Quoted 37 lines

-----Original Message-----
From: Florian Fainelli <[email protected]>
Sent: Wednesday, August 15, 2018 5:29 PM
To: Tristram Ha - C24268 <[email protected]>; Andrew Lunn <[email protected]>; Pavel Machek <[email protected]>; Ruediger Schmitt <[email protected]>
Cc: Arkadi Sharshevsky <[email protected]>; UNGLinuxDriver <[email protected]>; [email protected]
Subject: Re: [PATCH v2 net-next 0/8] net: dsa: microchip: Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers

Quoted 11 lines · On 12/05/2017 05:46 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.c so that it can handle many tail tag formats used by different KSZ switch drivers.

Quoted 8 lines

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.

Is something gating this series from getting included? It's been nearly 8 months now and this has not been include nor resubmitted, any plans to rebase that patch series and work towards inclusion in net-next when it opens back again?

Quoted 5 lines
Quoted 1 line

Thank you!

Sorry for the long delay. I will restart my kernel submission effort next month after finishing the work on current development project.

Tristram, any chance of resubmitting this or should someone with access to those switches take up your series and submit it?

Signature · 1 line
Florian