net: dsa: Mock-up driver
Subsystems (4)
PATCH 1/1 net: dsa: Mock-up driver
This patch adds support for a DSA mock-up driver which essentially does the following:
- registers/unregisters 4 fixed PHYs to the slave network devices
- uses eth0 (configurable) as the master netdev
- registers the switch as a fixed MDIO device against the fixed MDIO bus at address 31
- includes dynamic debug prints for dsa_switch_ops functions that can be enabled to get call traces
This is a good way to test modular builds as well as exercise the DSA APIs without requiring access to real hardware. This does not test the data-path, although this could be added later on.
--- drivers/net/dsa/Kconfig | 8 + drivers/net/dsa/Makefile | 2 +- drivers/net/dsa/dsa_loop.c | 329 ++++++++++++++++++++++++++++++++++++++ drivers/net/dsa/dsa_loop.h | 19 +++ drivers/net/dsa/dsa_loop_bdinfo.c | 34 ++++ include/linux/phy_fixed.h | 1 + 6 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 drivers/net/dsa/dsa_loop.c create mode 100644 drivers/net/dsa/dsa_loop.h create mode 100644 drivers/net/dsa/dsa_loop_bdinfo.c
drivers/net/dsa/Kconfig +8 -0
@@ -34,4 +34,12 @@ config NET_DSA_QCA8K This enables support for the Qualcomm Atheros QCA8K Ethernet switch chips. +config NET_DSA_LOOP + tristate "DSA mock-up Ethernet switch chip support" + depends on NET_DSA + select FIXED_PHY + ---help--- + This enables support for a fake mock-up switch chip which + exercises the DSA APIs. + endmenu
drivers/net/dsa/Makefile +1 -1
@@ -2,6 +2,6 @@ obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o obj-$(CONFIG_NET_DSA_BCM_SF2) += bcm-sf2.o bcm-sf2-objs := bcm_sf2.o bcm_sf2_cfp.o obj-$(CONFIG_NET_DSA_QCA8K) += qca8k.o - obj-y += b53/ obj-y += mv88e6xxx/ +obj-$(CONFIG_NET_DSA_LOOP) += dsa_loop.o dsa_loop_bdinfo.o
drivers/net/dsa/dsa_loop.c new file +329 -0
329 lines not on this page · raw message
drivers/net/dsa/dsa_loop.h new file +19 -0
@@ -0,0 +1,19 @@ +#ifndef __DSA_LOOP_H +#define __DSA_LOOP_H + +struct dsa_chip_data ; + +struct dsa_loop_pdata { +/* Must be first, such that dsa_register_switch() can access this +* without gory pointer manipulations +*/ +struct dsa_chip_data cd; +const char *name; +unsigned int enabled_ports; +const char *netdev; +}; + +#define DSA_LOOP_NUM_PORTS 6 +#define DSA_LOOP_CPU_PORT (DSA_LOOP_NUM_PORTS - 1) + +#endif /* __DSA_LOOP_H */
drivers/net/dsa/dsa_loop_bdinfo.c new file +34 -0
@@ -0,0 +1,34 @@ +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/phy.h> +#include <net/dsa.h> + +#include "dsa_loop.h" + +static struct dsa_loop_pdata dsa_loop_pdata = { + .cd = { + .port_names[0 ] ="lan1" , + .port_names[1 ] ="lan2" , + .port_names[2 ] ="lan3" , + .port_names[3 ] ="lan4" , + .port_names[DSA_LOOP_CPU_PORT ] ="cpu" , + }, + .name ="DSA mockup driver" , + .enabled_ports =0x1ff , + .netdev ="eth0" , +}; + +static const struct mdio_board_info bdinfo = { + .bus_id ="fixed-0" , + .modalias ="dsa-loop" , + .mdio_addr =31 , + .platform_data = &dsa_loop_pdata, +}; + +static int __init dsa_loop_bdinfo_init (void ) +{ +return mdiobus_register_board_info (&bdinfo,1 ); +} +arch_initcall(dsa_loop_bdinfo_init) + +MODULE_LICENSE("GPL");
include/linux/phy_fixed.h +1 -0
@@ -26,6 +26,7 @@ extern int fixed_phy_set_link_update(struct phy_device *phydev,extern int fixed_phy_update_state (struct phy_device *phydev,const struct fixed_phy_status *status,const struct fixed_phy_status *changed); +extern struct device *platform_fmb_bus_get (void );#else static inline int fixed_phy_add(unsigned int irq, int phy_id, struct fixed_phy_status *status,
Signature · 1 line
2.9.3
Quoted 22 lines · Florian Fainelli
This patch adds support for a DSA mock-up driver which essentially does the following:
- registers/unregisters 4 fixed PHYs to the slave network devices
- uses eth0 (configurable) as the master netdev
- registers the switch as a fixed MDIO device against the fixed MDIO bus at address 31
- includes dynamic debug prints fordsa_switch_opsfunctions that can be enabled to get call tracesThis is a good way to test modular builds as well as exercise the DSA APIs without requiring access to real hardware. This does not test the data-path, although this could be added later on.
Signed-off-by Florian Fainelli <[email protected]>---
include/linux/phy_fixed.h +0
-0
include/linux/phy_fixed.h extern int fixed_phy_set_link_update(struct phy_device *phydev, · line 29
Quoted 4 lines
include/linux/phy_fixed.h +1
-0@@ -26,6 +26,7 @@ extern int fixed_phy_set_link_update(struct phy_device *phydev,extern int fixed_phy_update_state (struct phy_device *phydev,const struct fixed_phy_status *status,const struct fixed_phy_status *changed); +extern struct device *platform_fmb_bus_get (void );
This is from a previous iteration of the driver and is no longer required, I will respin, provided that we see value in having this driver live in the kernel.
Signature · 1 line
Florian