Felix DSA driver cleanup: build Seville separately
Subsystems (4)
Vladimir Oltean
maintainercover Felix DSA driver cleanup: build Seville separately
From: Vladimir Oltean <[email protected]>
When introducing the Seville switch support to the Felix driver, some technical debt was created. Since both VSC9959 and VSC9953 are embedded switches (one on an arm64 SoC and the other on a powerpc SoC), there is no use case for having the code for both be present in the same module.
This was necessary at the time due to the common SERDES PCS code that they were using, but that has been since refactored into drivers/net/pcs/pcs-lynx.c.
This makes the Seville driver stop uselessly depending upon PCI and FSL_ENETC_MDIO, which were only dependencies of Felix in fact.
Some whitespace/tab conversions are also present in this series as part of the cleanup process.
Vladimir Oltean (11):
net: dsa: felix: use ocelot_field_{read,write} helpers consistently
net: dsa: seville: don't write to MEM_ENA twice
net: dsa: seville: first enable memories, then initialize them
net: dsa: ocelot: document why reset procedure is different for
felix/seville
net: dsa: seville: remove unused defines for the mdio controller
net: dsa: seville: reindent defines for MDIO controller
net: dsa: felix: replace tabs with spaces
net: dsa: seville: duplicate vsc9959_mdio_bus_free
net: mscc: ocelot: make ocelot_init_timestamp take a const struct
ptp_clock_info
net: dsa: felix: move the PTP clock structure to felix_vsc9959.c
net: dsa: seville: build as separate module
drivers/net/dsa/ocelot/Kconfig | 22 +++++---- drivers/net/dsa/ocelot/Makefile | 6 ++- drivers/net/dsa/ocelot/felix.c | 47 +------------------ drivers/net/dsa/ocelot/felix.h | 7 +-- drivers/net/dsa/ocelot/felix_vsc9959.c | 57 +++++++++++++++++------- drivers/net/dsa/ocelot/seville_vsc9953.c | 55 ++++++++++++++--------- drivers/net/ethernet/mscc/ocelot_ptp.c | 3 +- include/soc/mscc/ocelot_ptp.h | 3 +- 8 files changed, 102 insertions(+), 98 deletions(-)
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 1/11 net: dsa: felix: use ocelot_field_{read,write} helpers consistently
From: Vladimir Oltean <[email protected]>
Since these helpers for regmap fields are available, use them.
--- drivers/net/dsa/ocelot/felix_vsc9959.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +3 -3
@@ -727,7 +727,7 @@ static int vsc9959_gcb_soft_rst_status(struct ocelot *ocelot) {int val; -regmap_field_read (ocelot->regfields[GCB_SOFT_RST_SWC_RST ], &val); +ocelot_field_read (ocelot,GCB_SOFT_RST_SWC_RST , &val);return val; }
@@ -742,7 +742,7 @@ static int vsc9959_reset(struct ocelot *ocelot)int val, err;/* soft-reset the switch core */ -regmap_field_write (ocelot->regfields[GCB_SOFT_RST_SWC_RST ],1 ); +ocelot_field_write (ocelot,GCB_SOFT_RST_SWC_RST ,1 ); err =readx_poll_timeout (vsc9959_gcb_soft_rst_status, ocelot, val, !val,VSC9959_GCB_RST_SLEEP ,VSC9959_INIT_TIMEOUT );
@@ -762,7 +762,7 @@ static int vsc9959_reset(struct ocelot *ocelot) }/* enable switch core */ -regmap_field_write (ocelot->regfields[SYS_RESET_CFG_CORE_ENA ],1 ); +ocelot_field_write (ocelot,SYS_RESET_CFG_CORE_ENA ,1 );return 0 ; }
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 2/11 net: dsa: seville: don't write to MEM_ENA twice
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
There is another one of these right above the readx_poll_status.
--- drivers/net/dsa/ocelot/seville_vsc9953.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/dsa/ocelot/seville_vsc9953.c +0 -1
@@ -847,7 +847,6 @@ static int vsc9953_reset(struct ocelot *ocelot) }/* enable switch core */ -ocelot_field_write (ocelot,SYS_RESET_CFG_MEM_ENA ,1 );ocelot_field_write (ocelot,SYS_RESET_CFG_CORE_ENA ,1 );return 0 ;
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 3/11 net: dsa: seville: first enable memories, then initialize them
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
As per documentation, proper startup sequence is:
* Enable memories
* Initialize memories
* Enable core
--- drivers/net/dsa/ocelot/seville_vsc9953.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/ocelot/seville_vsc9953.c +1 -1
@@ -835,8 +835,8 @@ static int vsc9953_reset(struct ocelot *ocelot) }/* initialize switch mem ~40us */ -ocelot_field_write (ocelot,SYS_RESET_CFG_MEM_INIT ,1 );ocelot_field_write (ocelot,SYS_RESET_CFG_MEM_ENA ,1 ); +ocelot_field_write (ocelot,SYS_RESET_CFG_MEM_INIT ,1 ); err = readx_poll_timeout(vsc9953_sys_ram_init_status, ocelot, val, !val, VSC9953_SYS_RAMINIT_SLEEP,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 4/11 net: dsa: ocelot: document why reset procedure is different for felix/seville
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The overall idea (issue soft reset, enable memories, initialize memories, enable core) is the same, so it would make sense that an attempt is made to unify the procedures.
It is not immediately obvious that the fields are not part of the same register targets, though. So add a comment.
--- drivers/net/dsa/ocelot/felix_vsc9959.c | 3 +++ drivers/net/dsa/ocelot/seville_vsc9953.c | 4 ++++ 2 files changed, 7 insertions(+)
drivers/net/dsa/ocelot/felix_vsc9959.c +3 -0
@@ -737,6 +737,9 @@ static int vsc9959_sys_ram_init_status(struct ocelot *ocelot)return ocelot_read (ocelot,SYS_RAM_INIT ); } +/* CORE_ENA is in SYS:SYSTEM:RESET_CFG +* RAM_INIT is in SYS:RAM_CTRL:RAM_INIT +*/ static int vsc9959_reset (struct ocelot *ocelot) {int val, err;
drivers/net/dsa/ocelot/seville_vsc9953.c +4 -0
@@ -820,6 +820,10 @@ static int vsc9953_mdio_read(struct mii_bus *bus, int phy_id, int regnum)return err; } +/* CORE_ENA is in SYS:SYSTEM:RESET_CFG +* MEM_INIT is in SYS:SYSTEM:RESET_CFG +* MEM_ENA is in SYS:SYSTEM:RESET_CFG +*/ static int vsc9953_reset (struct ocelot *ocelot) {int val, err;
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 5/11 net: dsa: seville: remove unused defines for the mdio controller
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Some definitions were likely copied fromdrivers/net/mdio/mdio-mscc-miim.c.
They are not necessary, remove them.
--- drivers/net/dsa/ocelot/seville_vsc9953.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/net/dsa/ocelot/seville_vsc9953.c +0 -11
@@ -16,23 +16,12 @@#define VSC9953_VCAP_IS2_ENTRY_WIDTH 376#define VSC9953_VCAP_PORT_CNT 10 -#define MSCC_MIIM_REG_STATUS 0x0 -#define MSCC_MIIM_STATUS_STAT_BUSY BIT(3) -#define MSCC_MIIM_REG_CMD 0x8#define MSCC_MIIM_CMD_OPR_WRITE BIT(1)#define MSCC_MIIM_CMD_OPR_READ BIT(2)#define MSCC_MIIM_CMD_WRDATA_SHIFT 4#define MSCC_MIIM_CMD_REGAD_SHIFT 20#define MSCC_MIIM_CMD_PHYAD_SHIFT 25#define MSCC_MIIM_CMD_VLD BIT(31) -#define MSCC_MIIM_REG_DATA 0xC -#define MSCC_MIIM_DATA_ERROR (BIT(16) | BIT(17)) - -#define MSCC_PHY_REG_PHY_CFG 0x0 -#define PHY_CFG_PHY_ENA (BIT(0) | BIT(1) | BIT(2) | BIT(3)) -#define PHY_CFG_PHY_COMMON_RESET BIT(4) -#define PHY_CFG_PHY_RESET (BIT(5) | BIT(6) | BIT(7) | BIT(8)) -#define MSCC_PHY_REG_PHY_STATUS 0x4static const u32 vsc9953_ana_regmap[] = {REG (ANA_ADVLEARN ,0x00b500 ),
Signature · 1 line
2.25.1
Re: [PATCH net-next 05/11] net: dsa: seville: remove unused defines for the mdio controller
Quoted 6 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
Some definitions were likely copied from
drivers/net/mdio/mdio-mscc-miim.c.They are not necessary, remove them.
Seeing that the mdio controller is probably the same, couldn't mdio-mscc-miim be reused?
Quoted 37 lines
Signed-off-by Vladimir Oltean <[email protected]>--- drivers/net/dsa/ocelot/seville_vsc9953.c | 11 ----------- 1 file changed, 11 deletions(-)drivers/net/dsa/ocelot/seville_vsc9953.c +0
-11@@ -16,23 +16,12 @@#define VSC9953_VCAP_IS2_ENTRY_WIDTH 376#define VSC9953_VCAP_PORT_CNT 10 -#define MSCC_MIIM_REG_STATUS 0x0 -#define MSCC_MIIM_STATUS_STAT_BUSY BIT(3) -#define MSCC_MIIM_REG_CMD 0x8#define MSCC_MIIM_CMD_OPR_WRITE BIT(1)#define MSCC_MIIM_CMD_OPR_READ BIT(2)#define MSCC_MIIM_CMD_WRDATA_SHIFT 4#define MSCC_MIIM_CMD_REGAD_SHIFT 20#define MSCC_MIIM_CMD_PHYAD_SHIFT 25#define MSCC_MIIM_CMD_VLD BIT(31) -#define MSCC_MIIM_REG_DATA 0xC -#define MSCC_MIIM_DATA_ERROR (BIT(16) | BIT(17)) - -#define MSCC_PHY_REG_PHY_CFG 0x0 -#define PHY_CFG_PHY_ENA (BIT(0) | BIT(1) | BIT(2) | BIT(3)) -#define PHY_CFG_PHY_COMMON_RESET BIT(4) -#define PHY_CFG_PHY_RESET (BIT(5) | BIT(6) | BIT(7) | BIT(8)) -#define MSCC_PHY_REG_PHY_STATUS 0x4static const u32 vsc9953_ana_regmap[] = {REG (ANA_ADVLEARN ,0x00b500 ),Signature · 1 line
2.25.1
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Vladimir Oltean
maintainerRe: [PATCH net-next 05/11] net: dsa: seville: remove unused defines for the mdio controller
Quoted 10 lines · Alexandre Belloni
Quoted 6 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
Some definitions were likely copied from
drivers/net/mdio/mdio-mscc-miim.c.They are not necessary, remove them.
Seeing that the mdio controller is probably the same, couldn't mdio-mscc-miim be reused?
Yeah, it probably can, but for 75 lines of code, is it worth it to butcher mdio-mscc-miim too? I'm not sure at what level that reuse should be. Should we pass it our regmap? mdio-mscc-miim doesn't use regmap.
Re: [PATCH net-next 05/11] net: dsa: seville: remove unused defines for the mdio controller
Quoted 7 lines · Vladimir Oltean
Quoted 6 lines · Alexandre Belloni
Quoted 5 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
Some definitions were likely copied from
drivers/net/mdio/mdio-mscc-miim.c.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
They are not necessary, remove them.
Seeing that the mdio controller is probably the same, couldn't mdio-mscc-miim be reused?
Yeah, it probably can, but for 75 lines of code, is it worth it to butcher mdio-mscc-miim too? I'm not sure at what level that reuse should be. Should we pass it our regmap? mdio-mscc-miim doesn't use regmap.
It may be worth it, I'm going to add DSA support for ocelot over SPI. So to abstract the bus, it is probably worth moving to regmap.
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Vladimir Oltean
maintainerRe: [PATCH net-next 05/11] net: dsa: seville: remove unused defines for the mdio controller
Quoted 13 lines · Alexandre Belloni
Quoted 12 lines · Vladimir Oltean
Quoted 10 lines · Alexandre Belloni
Quoted 6 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
Some definitions were likely copied from
drivers/net/mdio/mdio-mscc-miim.c.They are not necessary, remove them.
Seeing that the mdio controller is probably the same, couldn't mdio-mscc-miim be reused?
Quoted 6 lines
Quoted 3 lines
Yeah, it probably can, but for 75 lines of code, is it worth it to butcher mdio-mscc-miim too? I'm not sure at what level that reuse should be. Should we pass it our regmap? mdio-mscc-miim doesn't use regmap.
It may be worth it, I'm going to add DSA support for ocelot over SPI. So to abstract the bus, it is probably worth moving to regmap.
Wow, that's interesting, tell me more. For traffic, will you be using an NPI port, or some other configuration?
And as for reusing mdio-mscc-miim, I think I'll look into that as a separate set of patches.
Thanks,
-Vladimir
Re: [PATCH net-next 05/11] net: dsa: seville: remove unused defines for the mdio controller
Quoted 18 lines · Vladimir Oltean
Quoted 17 lines · Alexandre Belloni
Quoted 15 lines · Vladimir Oltean
Quoted 10 lines · Alexandre Belloni
Quoted 6 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
Some definitions were likely copied from
drivers/net/mdio/mdio-mscc-miim.c.They are not necessary, remove them.
Seeing that the mdio controller is probably the same, couldn't mdio-mscc-miim be reused?
Yeah, it probably can, but for 75 lines of code, is it worth it to butcher mdio-mscc-miim too? I'm not sure at what level that reuse should be. Should we pass it our regmap? mdio-mscc-miim doesn't use regmap.
Quoted 6 lines
Quoted 2 lines
It may be worth it, I'm going to add DSA support for ocelot over SPI. So to abstract the bus, it is probably worth moving to regmap.
Wow, that's interesting, tell me more. For traffic, will you be using an NPI port, or some other configuration?
Yes, the plan is to use SPI for configuration and an NPI port for traffic. The internal MIPS CPU will be disabled. If I'm not mistaken, this is what is done for vsc73xx.
Quoted 3 lines
And as for reusing mdio-mscc-miim, I think I'll look into that as a separate set of patches.
No worries, I can also take care of that. Or maybe you are right and it doesn't make sense to do it.
Vladimir Oltean
maintainerPATCH 6/11 net: dsa: seville: reindent defines for MDIO controller
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Reindent these definitions to be in line with the rest of the driver.
--- drivers/net/dsa/ocelot/seville_vsc9953.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/dsa/ocelot/seville_vsc9953.c +6 -6
@@ -16,12 +16,12 @@#define VSC9953_VCAP_IS2_ENTRY_WIDTH 376#define VSC9953_VCAP_PORT_CNT 10 -#define MSCC_MIIM_CMD_OPR_WRITE BIT(1) -#define MSCC_MIIM_CMD_OPR_READ BIT(2) -#define MSCC_MIIM_CMD_WRDATA_SHIFT 4 -#define MSCC_MIIM_CMD_REGAD_SHIFT 20 -#define MSCC_MIIM_CMD_PHYAD_SHIFT 25 -#define MSCC_MIIM_CMD_VLD BIT(31) +#define MSCC_MIIM_CMD_OPR_WRITE BIT(1) +#define MSCC_MIIM_CMD_OPR_READ BIT(2) +#define MSCC_MIIM_CMD_WRDATA_SHIFT 4 +#define MSCC_MIIM_CMD_REGAD_SHIFT 20 +#define MSCC_MIIM_CMD_PHYAD_SHIFT 25 +#define MSCC_MIIM_CMD_VLD BIT(31)static const u32 vsc9953_ana_regmap[] = {REG (ANA_ADVLEARN ,0x00b500 ),
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 7/11 net: dsa: felix: replace tabs with spaces
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Over the time, some patches have introduced structures aligned with spaces, near structures aligned with tabs. Fix the inconsistencies.
--- drivers/net/dsa/ocelot/felix.c | 2 +- drivers/net/dsa/ocelot/felix.h | 2 +- drivers/net/dsa/ocelot/felix_vsc9959.c | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/dsa/ocelot/felix.c +1 -1
@@ -803,7 +803,7 @@ const struct dsa_switch_ops felix_switch_ops = { .cls_flower_add = felix_cls_flower_add, .cls_flower_del = felix_cls_flower_del, .cls_flower_stats = felix_cls_flower_stats, - .port_setup_tc = felix_port_setup_tc, + .port_setup_tc = felix_port_setup_tc, };static int __init felix_init (void )
drivers/net/dsa/ocelot/felix.h +1 -1
@@ -20,7 +20,7 @@ struct felix_info {const struct ocelot_stat_layout *stats_layout;unsigned int num_stats;int num_ports; -int num_tx_queues; +int num_tx_queues;struct vcap_field *vcap_is2_keys;struct vcap_field *vcap_is2_actions;const struct vcap_props *vcap;
drivers/net/dsa/ocelot/felix_vsc9959.c +11 -11
@@ -296,15 +296,15 @@ static const u32 vsc9959_sys_regmap[] = { };static const u32 vsc9959_ptp_regmap[] = { -REG (PTP_PIN_CFG ,0x000000 ), -REG (PTP_PIN_TOD_SEC_MSB ,0x000004 ), -REG (PTP_PIN_TOD_SEC_LSB ,0x000008 ), -REG (PTP_PIN_TOD_NSEC ,0x00000c ), -REG (PTP_PIN_WF_HIGH_PERIOD ,0x000014 ), -REG (PTP_PIN_WF_LOW_PERIOD ,0x000018 ), -REG (PTP_CFG_MISC ,0x0000a0 ), -REG (PTP_CLK_CFG_ADJ_CFG ,0x0000a4 ), -REG (PTP_CLK_CFG_ADJ_FREQ ,0x0000a8 ), +REG (PTP_PIN_CFG ,0x000000 ), +REG (PTP_PIN_TOD_SEC_MSB ,0x000004 ), +REG (PTP_PIN_TOD_SEC_LSB ,0x000008 ), +REG (PTP_PIN_TOD_NSEC ,0x00000c ), +REG (PTP_PIN_WF_HIGH_PERIOD ,0x000014 ), +REG (PTP_PIN_WF_LOW_PERIOD ,0x000018 ), +REG (PTP_CFG_MISC ,0x0000a0 ), +REG (PTP_CLK_CFG_ADJ_CFG ,0x0000a4 ), +REG (PTP_CLK_CFG_ADJ_FREQ ,0x0000a8 ), };static const u32 vsc9959_gcb_regmap[] = {
@@ -1173,8 +1173,8 @@ static const struct felix_info felix_info_vsc9959 = { .mdio_bus_free = vsc9959_mdio_bus_free, .phylink_validate = vsc9959_phylink_validate, .prevalidate_phy_mode = vsc9959_prevalidate_phy_mode, - .port_setup_tc = vsc9959_port_setup_tc, - .port_sched_speed_set = vsc9959_sched_speed_set, + .port_setup_tc = vsc9959_port_setup_tc, + .port_sched_speed_set = vsc9959_sched_speed_set, .xmit_template_populate = vsc9959_xmit_template_populate, };
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 8/11 net: dsa: seville: duplicate vsc9959_mdio_bus_free
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
While we don't plan on making any changes to this function, currently this is the only remaining dependency between felix and seville, after the PCS has been refactored out into pcs-lynx.c.
Duplicate this function in seville to break the dependency completely.
--- drivers/net/dsa/ocelot/felix.h | 2 -- drivers/net/dsa/ocelot/felix_vsc9959.c | 2 +- drivers/net/dsa/ocelot/seville_vsc9953.c | 19 ++++++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-)
drivers/net/dsa/ocelot/felix.h +0 -2
@@ -55,6 +55,4 @@ struct felix { resource_size_t imdio_base; }; -void vsc9959_mdio_bus_free (struct ocelot *ocelot); -#endif
drivers/net/dsa/ocelot/felix_vsc9959.c +1 -1
@@ -936,7 +936,7 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)return 0 ; } -void vsc9959_mdio_bus_free (struct ocelot *ocelot) +static void vsc9959_mdio_bus_free (struct ocelot *ocelot) {struct felix *felix =ocelot_to_felix (ocelot);int port;
drivers/net/dsa/ocelot/seville_vsc9953.c +18 -1
@@ -981,6 +981,23 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)return 0 ; } +static void vsc9953_mdio_bus_free (struct ocelot *ocelot) +{ +struct felix *felix =ocelot_to_felix (ocelot); +int port; + +for (port =0 ; port < ocelot->num_phys_ports; port++) { +struct lynx_pcs *pcs = felix->pcs[port]; + +if (!pcs) +continue ; + +mdio_device_free (pcs->mdio); +lynx_pcs_destroy (pcs); + } +mdiobus_unregister (felix->imdio); +} +static void vsc9953_xmit_template_populate (struct ocelot *ocelot,int port) {struct ocelot_port *ocelot_port = ocelot->ports[port];
@@ -1014,7 +1031,7 @@ static const struct felix_info seville_info_vsc9953 = { .num_mact_rows = 2048, .num_ports = 10, .mdio_bus_alloc = vsc9953_mdio_bus_alloc, - .mdio_bus_free = vsc9959_mdio_bus_free, + .mdio_bus_free = vsc9953_mdio_bus_free, .phylink_validate = vsc9953_phylink_validate, .prevalidate_phy_mode = vsc9953_prevalidate_phy_mode, .xmit_template_populate = vsc9953_xmit_template_populate,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 9/11 net: mscc: ocelot: make ocelot_init_timestamp take a const struct ptp_clock_info
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
It is a good measure to ensure correctness if the structures that are meant to remain constant are only processed by functions that thake constant arguments.
--- drivers/net/ethernet/mscc/ocelot_ptp.c | 3 ++- include/soc/mscc/ocelot_ptp.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mscc/ocelot_ptp.c +2 -1
@@ -300,7 +300,8 @@ int ocelot_ptp_enable(struct ptp_clock_info *ptp, }EXPORT_SYMBOL (ocelot_ptp_enable); -int ocelot_init_timestamp (struct ocelot *ocelot,struct ptp_clock_info *info) +int ocelot_init_timestamp (struct ocelot *ocelot, +const struct ptp_clock_info *info) {struct ptp_clock *ptp_clock;int i;
include/soc/mscc/ocelot_ptp.h +2 -1
@@ -53,6 +53,7 @@ int ocelot_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin, enum ptp_pin_function func, unsigned int chan);int ocelot_ptp_enable (struct ptp_clock_info *ptp,struct ptp_clock_request *rq,int on); -int ocelot_init_timestamp (struct ocelot *ocelot,struct ptp_clock_info *info); +int ocelot_init_timestamp (struct ocelot *ocelot, +const struct ptp_clock_info *info);int ocelot_deinit_timestamp (struct ocelot *ocelot);#endif
Signature · 1 line
2.25.1
Re: [PATCH net-next 09/11] net: mscc: ocelot: make ocelot_init_timestamp take a const struct ptp_clock_info
Quoted 7 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
It is a good measure to ensure correctness if the structures that are meant to remain constant are only processed by functions that thake constant arguments.
Signed-off-by Vladimir Oltean <[email protected]>
Quoted 35 lines
--- drivers/net/ethernet/mscc/ocelot_ptp.c | 3 ++- include/soc/mscc/ocelot_ptp.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)drivers/net/ethernet/mscc/ocelot_ptp.c +2
-1@@ -300,7 +300,8 @@ int ocelot_ptp_enable(struct ptp_clock_info *ptp, }EXPORT_SYMBOL (ocelot_ptp_enable); -int ocelot_init_timestamp (struct ocelot *ocelot,struct ptp_clock_info *info) +int ocelot_init_timestamp (struct ocelot *ocelot, +const struct ptp_clock_info *info) {struct ptp_clock *ptp_clock;int i;include/soc/mscc/ocelot_ptp.h +2
-1@@ -53,6 +53,7 @@ int ocelot_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin, enum ptp_pin_function func, unsigned int chan);int ocelot_ptp_enable (struct ptp_clock_info *ptp,struct ptp_clock_request *rq,int on); -int ocelot_init_timestamp (struct ocelot *ocelot,struct ptp_clock_info *info); +int ocelot_init_timestamp (struct ocelot *ocelot, +const struct ptp_clock_info *info);int ocelot_deinit_timestamp (struct ocelot *ocelot);#endif Signature · 1 line
2.25.1
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Vladimir Oltean
maintainerPATCH 10/11 net: dsa: felix: move the PTP clock structure to felix_vsc9959.c
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Not only does Sevile not have a PTP clock, but with separate modules, this structure cannot even live in felix.c, due to the .owner = THIS_MODULE assignment causing this link time error:
drivers/net/dsa/ocelot/felix.o:(.data+0x0): undefined reference to `__this_module'
--- drivers/net/dsa/ocelot/felix.c | 19 +------------------ drivers/net/dsa/ocelot/felix.h | 1 + drivers/net/dsa/ocelot/felix_vsc9959.c | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 18 deletions(-)
drivers/net/dsa/ocelot/felix.c +1 -18
@@ -538,23 +538,6 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)return 0 ; } -static struct ptp_clock_info ocelot_ptp_clock_info = { - .owner =THIS_MODULE , - .name ="felix ptp" , - .max_adj =0x7fffffff , - .n_alarm =0 , - .n_ext_ts =0 , - .n_per_out =OCELOT_PTP_PINS_NUM , - .n_pins =OCELOT_PTP_PINS_NUM , - .pps =0 , - .gettime64 = ocelot_ptp_gettime64, - .settime64 = ocelot_ptp_settime64, - .adjtime = ocelot_ptp_adjtime, - .adjfine = ocelot_ptp_adjfine, - .verify = ocelot_ptp_verify, - .enable = ocelot_ptp_enable, -}; -/* Hardware initialization done here so that we can allocate structures with * devm without fear of dsa_register_switch returning -EPROBE_DEFER and causing * us to allocate structures twice (leak memory) and map PCI memory twice
@@ -576,7 +559,7 @@ static int felix_setup(struct dsa_switch *ds)return err;if (ocelot->ptp) { - err =ocelot_init_timestamp (ocelot, &ocelot_ptp_clock_info); + err =ocelot_init_timestamp (ocelot, felix->info->ptp_caps);if (err) {dev_err (ocelot->dev,"Timestamp initialization failed\n" );
drivers/net/dsa/ocelot/felix.h +1 -0
@@ -26,6 +26,7 @@ struct felix_info {const struct vcap_props *vcap;int switch_pci_bar;int imdio_pci_bar; +const struct ptp_clock_info *ptp_caps;int (*mdio_bus_alloc)(struct ocelot *ocelot);void (*mdio_bus_free)(struct ocelot *ocelot); void (*phylink_validate)(struct ocelot *ocelot, int port,
drivers/net/dsa/ocelot/felix_vsc9959.c +18 -0
@@ -719,6 +719,23 @@ static const struct vcap_props vsc9959_vcap_props[] = { }, }; +static const struct ptp_clock_info vsc9959_ptp_caps = { + .owner =THIS_MODULE , + .name ="felix ptp" , + .max_adj =0x7fffffff , + .n_alarm =0 , + .n_ext_ts =0 , + .n_per_out =OCELOT_PTP_PINS_NUM , + .n_pins =OCELOT_PTP_PINS_NUM , + .pps =0 , + .gettime64 = ocelot_ptp_gettime64, + .settime64 = ocelot_ptp_settime64, + .adjtime = ocelot_ptp_adjtime, + .adjfine = ocelot_ptp_adjfine, + .verify = ocelot_ptp_verify, + .enable = ocelot_ptp_enable, +}; +#define VSC9959_INIT_TIMEOUT 50000#define VSC9959_GCB_RST_SLEEP 100#define VSC9959_SYS_RAMINIT_SLEEP 80
@@ -1169,6 +1186,7 @@ static const struct felix_info felix_info_vsc9959 = { .num_tx_queues = FELIX_NUM_TC, .switch_pci_bar = 4, .imdio_pci_bar = 0, + .ptp_caps = &vsc9959_ptp_caps, .mdio_bus_alloc = vsc9959_mdio_bus_alloc, .mdio_bus_free = vsc9959_mdio_bus_free, .phylink_validate = vsc9959_phylink_validate,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 11/11 net: dsa: seville: build as separate module
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Seville does not need to depend on PCI or on the ENETC MDIO controller. There will also be other compile-time differences in the future.
--- drivers/net/dsa/ocelot/Kconfig | 22 ++++++++++++-------- drivers/net/dsa/ocelot/Makefile | 6 +++++- drivers/net/dsa/ocelot/felix.c | 26 ------------------------ drivers/net/dsa/ocelot/felix.h | 2 -- drivers/net/dsa/ocelot/felix_vsc9959.c | 6 +++++- drivers/net/dsa/ocelot/seville_vsc9953.c | 6 +++++- 6 files changed, 29 insertions(+), 39 deletions(-)
drivers/net/dsa/ocelot/Kconfig +14 -8
@@ -10,11 +10,17 @@ config NET_DSA_MSCC_FELIX select FSL_ENETC_MDIO select PCS_LYNX help - This driver supports network switches from the Vitesse / - Microsemi / Microchip Ocelot family of switching cores that are - connected to their host CPU via Ethernet. - The following switches are supported: - - VSC9959 (Felix): embedded as a PCIe function of the NXP LS1028A - ENETC integrated endpoint. - - VSC9953 (Seville): embedded as a platform device on the - NXP T1040 SoC. + This driver supports the VSC9959 (Felix) switch, which is embedded as + a PCIe function of the NXP LS1028A ENETC RCiEP. + +config NET_DSA_MSCC_SEVILLE + tristate "Ocelot / Seville Ethernet switch support" + depends on NET_DSA + depends on NET_VENDOR_MICROSEMI + depends on HAS_IOMEM + select MSCC_OCELOT_SWITCH_LIB + select NET_DSA_TAG_OCELOT + select PCS_LYNX + help + This driver supports the VSC9953 (Seville) switch, which is embedded + as a platform device on the NXP T1040 SoC.
drivers/net/dsa/ocelot/Makefile +5 -1
@@ -1,7 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_NET_DSA_MSCC_FELIX) += mscc_felix.o +obj-$(CONFIG_NET_DSA_MSCC_SEVILLE) += mscc_seville.o mscc_felix-objs := \ felix.o \ - felix_vsc9959.o \ + felix_vsc9959.o + +mscc_seville-objs := \ + felix.o \ seville_vsc9953.o
drivers/net/dsa/ocelot/felix.c +0 -26
@@ -788,29 +788,3 @@ const struct dsa_switch_ops felix_switch_ops = { .cls_flower_stats = felix_cls_flower_stats, .port_setup_tc = felix_port_setup_tc, }; - -static int __init felix_init (void ) -{ -int err; - - err =pci_register_driver (&felix_vsc9959_pci_driver); -if (err) -return err; - - err =platform_driver_register (&seville_vsc9953_driver); -if (err) -return err; - -return 0 ; -} -module_init (felix_init); - -static void __exit felix_exit(void) -{ -pci_unregister_driver (&felix_vsc9959_pci_driver); -platform_driver_unregister (&seville_vsc9953_driver); -} -module_exit (felix_exit); - -MODULE_DESCRIPTION ("Felix Switch driver" ); -MODULE_LICENSE ("GPL v2" );
drivers/net/dsa/ocelot/felix.h +0 -2
@@ -42,8 +42,6 @@ struct felix_info { };extern const struct dsa_switch_ops felix_switch_ops; -extern struct pci_driver felix_vsc9959_pci_driver; -extern struct platform_driver seville_vsc9953_driver;/* DSA glue / front-end for struct ocelot */ struct felix {
drivers/net/dsa/ocelot/felix_vsc9959.c +5 -1
@@ -1328,9 +1328,13 @@ static struct pci_device_id felix_ids[] = { };MODULE_DEVICE_TABLE (pci, felix_ids); -struct pci_driver felix_vsc9959_pci_driver = { +static struct pci_driver felix_vsc9959_pci_driver = { .name ="mscc_felix" , .id_table = felix_ids, .probe = felix_pci_probe, .remove = felix_pci_remove, }; +module_pci_driver (felix_vsc9959_pci_driver); + +MODULE_DESCRIPTION ("Felix Switch driver" ); +MODULE_LICENSE ("GPL v2" );
drivers/net/dsa/ocelot/seville_vsc9953.c +5 -1
@@ -1110,7 +1110,7 @@ static const struct of_device_id seville_of_match[] = { };MODULE_DEVICE_TABLE (of, seville_of_match); -struct platform_driver seville_vsc9953_driver = { +static struct platform_driver seville_vsc9953_driver = { .probe = seville_probe, .remove = seville_remove, .driver = {
@@ -1118,3 +1118,7 @@ struct platform_driver seville_vsc9953_driver = { .of_match_table = of_match_ptr(seville_of_match), }, }; +module_platform_driver (seville_vsc9953_driver); + +MODULE_DESCRIPTION ("Seville Switch driver" ); +MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.25.1