Skip to contentSkip to conversation

net: phy: split the mscc driver

PATCH In review Antoine Tenart 2 participants 5 messages Mar 13, 2020 – Mar 15, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover net: phy: split the mscc driver

Hello,

This is a proposal to split the MSCC PHY driver, as its code base grew a lot lately (it's already 3800+ lines). It also supports features requiring a lot of code (MACsec), which would gain in being split from the driver core, for readability and maintenance. This is also done as other features should be coming later, which will also need lots of code addition.

This series shouldn't change the way the driver works.

I checked, and there were no patch pending on this driver. This change was done on top of all the modifications done on this driver in net-next.

Thanks,
Antoine

Since v2:
- Defined inline functions as static inline.
- Fixed a locking issue reported by Kbuild.

Since v1:
- Moved more definitions into the mscc_macsec.h header.

Antoine Tenart (3):
net: phy: move the mscc driver to its own directory
net: phy: mscc: split the driver into separate files
net: phy: mscc: fix header defines and descriptions

 drivers/net/phy/Makefile                     |    2 +-
 drivers/net/phy/mscc/Makefile                |   10 +
 drivers/net/phy/mscc/mscc.h                  |  392 +++++
 drivers/net/phy/{ => mscc}/mscc_fc_buffer.h  |    8 +-
 drivers/net/phy/{ => mscc}/mscc_mac.h        |    8 +-
 drivers/net/phy/mscc/mscc_macsec.c           | 1051 +++++++++++++
 drivers/net/phy/{ => mscc}/mscc_macsec.h     |   66 +-
 drivers/net/phy/{mscc.c => mscc/mscc_main.c} | 1469 +-----------------
 8 files changed, 1532 insertions(+), 1474 deletions(-)
 create mode 100644 drivers/net/phy/mscc/Makefile
 create mode 100644 drivers/net/phy/mscc/mscc.h
 rename drivers/net/phy/{ => mscc}/mscc_fc_buffer.h (95%)
 rename drivers/net/phy/{ => mscc}/mscc_mac.h (98%)
 create mode 100644 drivers/net/phy/mscc/mscc_macsec.c
 rename drivers/net/phy/{ => mscc}/mscc_macsec.h (90%)
 rename drivers/net/phy/{mscc.c => mscc/mscc_main.c} (60%)
Signature · 1 line
2.24.1
#1 lore raw

PATCH v3 1/3 net: phy: move the mscc driver to its own directory

The MSCC PHY driver is growing, with lots of space consuming features (firmware support, full initialization, MACsec...). It's becoming hard to read and navigate in its source code. This patch moves the MSCC driver to its own directory, without modifying anything, as a preparation for splitting up its features into dedicated files.

---
 drivers/net/phy/Makefile                    | 2 +-
 drivers/net/phy/mscc/Makefile               | 5 +++++
 drivers/net/phy/{ => mscc}/mscc.c           | 0
 drivers/net/phy/{ => mscc}/mscc_fc_buffer.h | 0
 drivers/net/phy/{ => mscc}/mscc_mac.h       | 0
 drivers/net/phy/{ => mscc}/mscc_macsec.h    | 0
 6 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/phy/mscc/Makefile
 rename drivers/net/phy/{ => mscc}/mscc.c (100%)
 rename drivers/net/phy/{ => mscc}/mscc_fc_buffer.h (100%)
 rename drivers/net/phy/{ => mscc}/mscc_mac.h (100%)
 rename drivers/net/phy/{ => mscc}/mscc_macsec.h (100%)
drivers/net/phy/Makefile +1 -1
index 26f8039f300f..70774ab474e6 100644
@@ -89,7 +89,7 @@ obj-$(CONFIG_MICREL_KS8995MA)	+= spi_ks8995.o
 obj-$(CONFIG_MICREL_PHY)	+= micrel.o
 obj-$(CONFIG_MICROCHIP_PHY)	+= microchip.o
 obj-$(CONFIG_MICROCHIP_T1_PHY)	+= microchip_t1.o
-obj-$(CONFIG_MICROSEMI_PHY)	+= mscc.o
+obj-$(CONFIG_MICROSEMI_PHY)	+= mscc/
 obj-$(CONFIG_NATIONAL_PHY)	+= national.o
 obj-$(CONFIG_NXP_TJA11XX_PHY)	+= nxp-tja11xx.o
 obj-$(CONFIG_QSEMI_PHY)		+= qsemi.o
drivers/net/phy/mscc/Makefile new file +5 -0
new file mode 100644
index 000000000000..e419ed1a3213
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for MSCC networking PHY driver
+
+obj-$(CONFIG_MICROSEMI_PHY) += mscc.o
drivers/net/phy/mscc/mscc.c renamed from drivers/net/phy/mscc.c +0 -0
similarity index 100%
rename from drivers/net/phy/mscc.c
rename to drivers/net/phy/mscc/mscc.c
drivers/net/phy/mscc/mscc_fc_buffer.h renamed from drivers/net/phy/mscc_fc_buffer.h +0 -0
similarity index 100%
rename from drivers/net/phy/mscc_fc_buffer.h
rename to drivers/net/phy/mscc/mscc_fc_buffer.h
drivers/net/phy/mscc/mscc_mac.h renamed from drivers/net/phy/mscc_mac.h +0 -0
similarity index 100%
rename from drivers/net/phy/mscc_mac.h
rename to drivers/net/phy/mscc/mscc_mac.h
drivers/net/phy/mscc/mscc_macsec.h renamed from drivers/net/phy/mscc_macsec.h +0 -0
similarity index 100%
rename from drivers/net/phy/mscc_macsec.h
rename to drivers/net/phy/mscc/mscc_macsec.h
Signature · 1 line
2.24.1
#2 lore raw

PATCH v3 2/3 net: phy: mscc: split the driver into separate files

In reply to Antoine Tenart

This patch splits the MSCC driver into separate files, per functionality, to improve readability and maintenance as the codebase grew a lot. The MACsec code is moved to a dedicated mscc_macsec.c file, the mscc.c file is renamed to mscc_main.c to keep the driver binary to be named mscc and common definition are put into a new mscc.h header.

Most of the code was just moved around, except for a few exceptions:
- Header inclusions were reworked to only keep what's needed.
- Three helpers were created in the MACsec code, to avoid #ifdef's in the main C file: vsc8584_macsec_init, vsc8584_handle_macsec_interrupt and vsc8584_config_macsec_intr.

The patch should not introduce any functional modification.

---
 drivers/net/phy/mscc/Makefile                |    7 +-
 drivers/net/phy/mscc/mscc.h                  |  392 +++++
 drivers/net/phy/mscc/mscc_macsec.c           | 1051 +++++++++++++
 drivers/net/phy/mscc/mscc_macsec.h           |   58 +
 drivers/net/phy/mscc/{mscc.c => mscc_main.c} | 1469 +-----------------
 5 files changed, 1515 insertions(+), 1462 deletions(-)
 create mode 100644 drivers/net/phy/mscc/mscc.h
 create mode 100644 drivers/net/phy/mscc/mscc_macsec.c
 rename drivers/net/phy/mscc/{mscc.c => mscc_main.c} (60%)
drivers/net/phy/mscc/Makefile +6 -1
index e419ed1a3213..10af42cd9839 100644
@@ -2,4 +2,9 @@
 #
 # Makefile for MSCC networking PHY driver
 
-obj-$(CONFIG_MICROSEMI_PHY) += mscc.o
+obj-$(CONFIG_MICROSEMI_PHY) := mscc.o
+mscc-objs := mscc_main.o
+
+ifdef CONFIG_MACSEC
+mscc-objs += mscc_macsec.o
+endif
drivers/net/phy/mscc/mscc.h new file +392 -0

392 lines not on this page · raw message

drivers/net/phy/mscc/mscc_macsec.c new file +1051 -0

1,051 lines not on this page · raw message

drivers/net/phy/mscc/mscc_macsec.h +58 -0

70 lines not on this page · raw message

drivers/net/phy/mscc/mscc_main.c renamed from drivers/net/phy/mscc/mscc.c +8 -1461

1,477 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.24.1

Part of the diff is not shown here. View the raw message.

#3 lore raw

PATCH v3 3/3 net: phy: mscc: fix header defines and descriptions

In reply to Antoine Tenart

Cosmetic commit fixing the MSCC PHY header defines and descriptions, which were referring the to MSCC Ocelot MAC driver (see drivers/net/ethernet/mscc/).

---
 drivers/net/phy/mscc/mscc_fc_buffer.h | 8 ++++----
 drivers/net/phy/mscc/mscc_mac.h       | 8 ++++----
 drivers/net/phy/mscc/mscc_macsec.h    | 8 ++++----
 3 files changed, 12 insertions(+), 12 deletions(-)
drivers/net/phy/mscc/mscc_fc_buffer.h +4 -4
index 7e9c0e877895..3803e826c37d 100644
@@ -1,12 +1,12 @@
 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
 /*
- * Microsemi Ocelot Switch driver
+ * Driver for Microsemi VSC85xx PHYs
  *
  * Copyright (C) 2019 Microsemi Corporation
  */
 
-#ifndef _MSCC_OCELOT_FC_BUFFER_H_
-#define _MSCC_OCELOT_FC_BUFFER_H_
+#ifndef _MSCC_PHY_FC_BUFFER_H_
+#define _MSCC_PHY_FC_BUFFER_H_
 
 #define MSCC_FCBUF_ENA_CFG					0x00
 #define MSCC_FCBUF_MODE_CFG					0x01
@@ -61,4 +61,4 @@
 #define MSCC_FCBUF_FC_READ_THRESH_CFG_RX_THRESH(x)		((x) << 16)
 #define MSCC_FCBUF_FC_READ_THRESH_CFG_RX_THRESH_M		GENMASK(31, 16)
 
-#endif
+#endif /* _MSCC_PHY_FC_BUFFER_H_ */
drivers/net/phy/mscc/mscc_mac.h +4 -4
index 9420ee5175a6..fcb5ba5e5d03 100644
@@ -1,12 +1,12 @@
 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
 /*
- * Microsemi Ocelot Switch driver
+ * Driver for Microsemi VSC85xx PHYs
  *
  * Copyright (c) 2017 Microsemi Corporation
  */
 
-#ifndef _MSCC_OCELOT_LINE_MAC_H_
-#define _MSCC_OCELOT_LINE_MAC_H_
+#ifndef _MSCC_PHY_LINE_MAC_H_
+#define _MSCC_PHY_LINE_MAC_H_
 
 #define MSCC_MAC_CFG_ENA_CFG					0x00
 #define MSCC_MAC_CFG_MODE_CFG					0x01
@@ -156,4 +156,4 @@
 #define MSCC_PROC_0_IP_1588_TOP_CFG_STAT_MODE_CTL_PROTOCOL_MODE(x)	(x)
 #define MSCC_PROC_0_IP_1588_TOP_CFG_STAT_MODE_CTL_PROTOCOL_MODE_M	GENMASK(2, 0)
 
-#endif /* _MSCC_OCELOT_LINE_MAC_H_ */
+#endif /* _MSCC_PHY_LINE_MAC_H_ */
drivers/net/phy/mscc/mscc_macsec.h +4 -4
index c606c9a65d2d..d0783944d106 100644
@@ -1,12 +1,12 @@
 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
 /*
- * Microsemi Ocelot Switch driver
+ * Driver for Microsemi VSC85xx PHYs
  *
  * Copyright (c) 2018 Microsemi Corporation
  */
 
-#ifndef _MSCC_OCELOT_MACSEC_H_
-#define _MSCC_OCELOT_MACSEC_H_
+#ifndef _MSCC_PHY_MACSEC_H_
+#define _MSCC_PHY_MACSEC_H_
 
 #include <net/macsec.h>
 
@@ -321,4 +321,4 @@ struct macsec_flow {
 #define MSCC_MS_INTR_CTRL_STATUS_INTR_ENABLE_M		GENMASK(31, 16)
 #define MACSEC_INTR_CTRL_STATUS_ROLLOVER		BIT(5)
 
-#endif
+#endif /* _MSCC_PHY_MACSEC_H_ */
Signature · 1 line
2.24.1
maintainer
#4 lore raw
In reply to Antoine Tenart

From: Antoine Tenart <[email protected]>
Date: Fri, 13 Mar 2020 10:47:59 +0100

Quoted 11 lines

This is a proposal to split the MSCC PHY driver, as its code base grew a lot lately (it's already 3800+ lines). It also supports features requiring a lot of code (MACsec), which would gain in being split from the driver core, for readability and maintenance. This is also done as other features should be coming later, which will also need lots of code addition.

This series shouldn't change the way the driver works.

I checked, and there were no patch pending on this driver. This change was done on top of all the modifications done on this driver in net-next.

...

Series applied, thanks Antoine.