net: dsa: b53: convert to phylink_pcs
PATCH 1/1 net: dsa: b53: convert to phylink_pcs
From: "Russell King (Oracle)" <[email protected]>
Convert B53 to use phylink_pcs for the serdes rather than hooking it into the MAC-layer callbacks.
Fixes 81c1681cbb9f ("net: dsa: b53: mark as non-legacy")
Reviewed-by Florian Fainelli <[email protected]>
Tested-by Florian Fainelli <[email protected]>
Signed-off-by Russell King (Oracle) <[email protected]>
--- drivers/net/dsa/b53/b53_common.c | 36 +++------------- drivers/net/dsa/b53/b53_priv.h | 24 ++++++----- drivers/net/dsa/b53/b53_serdes.c | 74 ++++++++++++++++++++++---------- drivers/net/dsa/b53/b53_serdes.h | 9 ++-- drivers/net/dsa/b53/b53_srab.c | 4 +- 5 files changed, 75 insertions(+), 72 deletions(-)
drivers/net/dsa/b53/b53_common.c +7 -29
@@ -1354,46 +1354,25 @@ static void b53_phylink_get_caps(struct dsa_switch *ds, int port, config->legacy_pre_march2020 = false; } -int b53_phylink_mac_link_state (struct dsa_switch *ds,int port, -struct phylink_link_state *state) +static struct phylink_pcs *b53_phylink_mac_select_pcs (struct dsa_switch *ds, +int port, +phy_interface_t interface) {struct b53_device *dev = ds->priv; -int ret = -EOPNOTSUPP ; -if ((phy_interface_mode_is_8023z (state->interface) || - state->interface ==PHY_INTERFACE_MODE_SGMII ) && - dev->ops->serdes_link_state) - ret = dev->ops->serdes_link_state (dev, port, state); +if (!dev->ops->phylink_mac_select_pcs) +return NULL ; -return ret; +return dev->ops->phylink_mac_select_pcs (dev, port, interface); } -EXPORT_SYMBOL (b53_phylink_mac_link_state);void b53_phylink_mac_config (struct dsa_switch *ds,int port,unsigned int mode,const struct phylink_link_state *state) { -struct b53_device *dev = ds->priv; - -if (mode ==MLO_AN_PHY || mode ==MLO_AN_FIXED ) -return ; - -if ((phy_interface_mode_is_8023z (state->interface) || - state->interface ==PHY_INTERFACE_MODE_SGMII ) && - dev->ops->serdes_config) - dev->ops->serdes_config (dev, port, mode, state); }EXPORT_SYMBOL (b53_phylink_mac_config); -void b53_phylink_mac_an_restart (struct dsa_switch *ds,int port) -{ -struct b53_device *dev = ds->priv; - -if (dev->ops->serdes_an_restart) - dev->ops->serdes_an_restart (dev, port); -} -EXPORT_SYMBOL (b53_phylink_mac_an_restart); -void b53_phylink_mac_link_down (struct dsa_switch *ds,int port,unsigned int mode,phy_interface_t interface)
@@ -2269,9 +2248,8 @@ static const struct dsa_switch_ops b53_switch_ops = { .phy_write = b53_phy_write16, .adjust_link = b53_adjust_link, .phylink_get_caps = b53_phylink_get_caps, - .phylink_mac_link_state = b53_phylink_mac_link_state, + .phylink_mac_select_pcs = b53_phylink_mac_select_pcs, .phylink_mac_config = b53_phylink_mac_config, - .phylink_mac_an_restart = b53_phylink_mac_an_restart, .phylink_mac_link_down = b53_phylink_mac_link_down, .phylink_mac_link_up = b53_phylink_mac_link_up, .port_enable = b53_enable_port,
drivers/net/dsa/b53/b53_priv.h +13 -11
@@ -21,7 +21,7 @@#include <linux/kernel.h> #include <linux/mutex.h> -#include <linux/phy.h> +#include <linux/phylink.h> #include <linux/etherdevice.h> #include <net/dsa.h>
@@ -29,7 +29,6 @@struct b53_device ;struct net_device ; -struct phylink_link_state ;struct b53_io_ops {int (*read8)(struct b53_device *dev,u8 page,u8 reg,u8 *value);
@@ -48,13 +47,10 @@ struct b53_io_ops {void (*irq_disable)(struct b53_device *dev,int port);void (*phylink_get_caps)(struct b53_device *dev,int port,struct phylink_config *config); +struct phylink_pcs *(*phylink_mac_select_pcs)(struct b53_device *dev, +int port, +phy_interface_t interface);u8 (*serdes_map_lane)(struct b53_device *dev,int port); -int (*serdes_link_state)(struct b53_device *dev,int port, -struct phylink_link_state *state); -void (*serdes_config)(struct b53_device *dev,int port, -unsigned int mode, -const struct phylink_link_state *state); -void (*serdes_an_restart)(struct b53_device *dev,int port);void (*serdes_link_set)(struct b53_device *dev,int port,unsigned int mode,phy_interface_t interface,bool link_up);
@@ -85,8 +81,15 @@ enum { BCM7278_DEVICE_ID = 0x7278, }; +struct b53_pcs { +struct phylink_pcs pcs; +struct b53_device *dev; +u8 lane; +}; +#define B53_N_PORTS 9#define B53_N_PORTS_25 6 +#define B53_N_PCS 2struct b53_port {u16 vlan_ctl_mask;
@@ -143,6 +146,8 @@ struct b53_device {bool vlan_enabled;unsigned int num_ports;struct b53_port *ports; + +struct b53_pcs pcs[B53_N_PCS ]; };#define b53_for_each_port (dev, i) \
@@ -336,12 +341,9 @@ int b53_br_flags(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack);int b53_setup_devlink_resources (struct dsa_switch *ds);void b53_port_event (struct dsa_switch *ds,int port); -int b53_phylink_mac_link_state (struct dsa_switch *ds,int port, -struct phylink_link_state *state);void b53_phylink_mac_config (struct dsa_switch *ds,int port,unsigned int mode,const struct phylink_link_state *state); -void b53_phylink_mac_an_restart (struct dsa_switch *ds,int port);void b53_phylink_mac_link_down (struct dsa_switch *ds,int port,unsigned int mode,phy_interface_t interface);
drivers/net/dsa/b53/b53_serdes.c +51 -23
139 lines not on this page · raw message
drivers/net/dsa/b53/b53_serdes.h +3 -6
@@ -107,14 +107,11 @@ static inline u8 b53_serdes_map_lane(struct b53_device *dev, int port)return dev->ops->serdes_map_lane (dev, port); } -int b53_serdes_get_link (struct b53_device *dev,int port); -int b53_serdes_link_state (struct b53_device *dev,int port, -struct phylink_link_state *state); -void b53_serdes_config (struct b53_device *dev,int port,unsigned int mode, -const struct phylink_link_state *state); -void b53_serdes_an_restart (struct b53_device *dev,int port);void b53_serdes_link_set (struct b53_device *dev,int port,unsigned int mode,phy_interface_t interface,bool link_up); +struct phylink_pcs *b53_serdes_phylink_mac_select_pcs (struct b53_device *dev, +int port, +phy_interface_t interface);void b53_serdes_phylink_get_caps (struct b53_device *dev,int port,struct phylink_config *config);#if IS_ENABLED (CONFIG_B53_SERDES )
drivers/net/dsa/b53/b53_srab.c +1 -3
@@ -491,10 +491,8 @@ static const struct b53_io_ops b53_srab_ops = { .irq_disable = b53_srab_irq_disable, .phylink_get_caps = b53_srab_phylink_get_caps,#if IS_ENABLED (CONFIG_B53_SERDES ) + .phylink_mac_select_pcs = b53_serdes_phylink_mac_select_pcs, .serdes_map_lane = b53_srab_serdes_map_lane, - .serdes_link_state = b53_serdes_link_state, - .serdes_config = b53_serdes_config, - .serdes_an_restart = b53_serdes_an_restart, .serdes_link_set = b53_serdes_link_set,#endif };
Signature · 1 line
2.25.1
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 11 lines · On Fri, 29 Apr 2022 09:43:03 -0700 you wrote:
From: "Russell King (Oracle)" <[email protected]>
Convert B53 to use
phylink_pcsfor the serdes rather than hooking it into the MAC-layer callbacks.Fixes 81c1681cbb9f ("net: dsa: b53: mark as non-legacy")Reviewed-by Florian Fainelli <[email protected]>Tested-by Florian Fainelli <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>[...]
Here is the summary with links:
- [net] net: dsa: b53: convert to phylink_pcs
https://git.kernel.org/netdev/net/c/79396934e289
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html