net: airoha: initial phylink support
Subsystems (4)
v2 cover net: airoha: initial phylink support
This trivial patch adds the initial phylink support. It's expected in the future to add the dedicated PCS for the other GDM port.
This is to give consistent data when running ethtool on the GDM1 port instead of the "No Data"
Changes v2:
- Move setup phylink to airoha_alloc_gdm_port
- Better handle phylink_destroy on error path
- Fix bug for device_get_phy_mode
Christian Marangi (2):
net: airoha: use device_set_node helper to setup GDM node
net: airoha: add phylink support for GDM1
drivers/net/ethernet/airoha/Kconfig | 1 + drivers/net/ethernet/airoha/airoha_eth.c | 79 +++++++++++++++++++++++- drivers/net/ethernet/airoha/airoha_eth.h | 3 + 3 files changed, 81 insertions(+), 2 deletions(-)
Signature · 1 line
2.51.0
PATCH v2 1/2 net: airoha: use device_set_node helper to setup GDM node
Use device_set_node helper to setup GDM node instead of manually setting the dev.of_node to also fill the fwnode entry.
This is to address some API that use fwnode instead of of_node (for example phylink_create)
--- drivers/net/ethernet/airoha/airoha_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/airoha/airoha_eth.c +1 -1
@@ -2904,7 +2904,7 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth,NETIF_F_HW_TC ; dev->features |= dev->hw_features; dev->vlan_features = dev->hw_features; - dev->dev.of_node = np; +device_set_node (&dev->dev,of_fwnode_handle (np)); dev->irq = qdma->irq_banks[0 ].irq;SET_NETDEV_DEV (dev, eth->dev);
Signature · 1 line
2.51.0
PATCH v2 2/2 net: airoha: add phylink support for GDM1
In reply to Christian MarangiIn preparation for support of GDM2+ port, fill in phylink OPs for GDM1 that is an INTERNAL port for the Embedded Switch.
Add all the phylink start/stop and fill in the MAC capabilities and the internal interface as the supported interface.
--- drivers/net/ethernet/airoha/Kconfig | 1 + drivers/net/ethernet/airoha/airoha_eth.c | 77 +++++++++++++++++++++++- drivers/net/ethernet/airoha/airoha_eth.h | 3 + 3 files changed, 80 insertions(+), 1 deletion(-)
drivers/net/ethernet/airoha/Kconfig +1 -0
@@ -2,6 +2,7 @@ config NET_VENDOR_AIROHA bool "Airoha devices" depends on ARCH_AIROHA || COMPILE_TEST + select PHYLIB help If you have a Airoha SoC with ethernet, say Y.
drivers/net/ethernet/airoha/airoha_eth.c +76 -1
124 lines not on this page · raw message
drivers/net/ethernet/airoha/airoha_eth.h +3 -0
@@ -531,6 +531,9 @@ struct airoha_gdm_port {struct net_device *dev;int id; +struct phylink *phylink; +struct phylink_config phylink_config; +struct airoha_hw_stats stats;DECLARE_BITMAP (qos_sq_bmap,AIROHA_NUM_QOS_CHANNELS );
Signature · 1 line
2.51.0
Re: [net-next PATCH v2 2/2] net: airoha: add phylink support for GDM1
Quoted 2 lines
In preparation for support of GDM2+ port, fill in phylink OPs for GDM1 that is an INTERNAL port for the Embedded Switch.
Hi Christian,
just few nitpicks inline. Fixing them:
Quoted 11 lines
Add all the phylink start/stop and fill in the MAC capabilities and the internal interface as the supported interface.
Signed-off-by Christian Marangi <[email protected]>--- drivers/net/ethernet/airoha/Kconfig | 1 + drivers/net/ethernet/airoha/airoha_eth.c | 77 +++++++++++++++++++++++- drivers/net/ethernet/airoha/airoha_eth.h | 3 + 3 files changed, 80 insertions(+), 1 deletion(-)
[...]
drivers/net/ethernet/airoha/airoha_eth.c static const struct ethtool_ops airoha_ethtool_ops = { · line 2821
Quoted 6 lines
drivers/net/ethernet/airoha/airoha_eth.c +2
-0@@ -2813,6 +2817,18 @@ static const struct ethtool_ops airoha_ethtool_ops = { .get_link = ethtool_op_get_link, }; +static struct phylink_pcs *airoha_phylink_mac_select_pcs (struct phylink_config *config, +phy_interface_t interface)
can you please do not go over 79 columns? (I still like it :))
static struct phylink_pcs * airoha_phylink_mac_select_pcs(struct phylink_config *config,
phy_interface_t interface)
{
return NULL;
}Quoted 25 lines
drivers/net/ethernet/airoha/airoha_eth.c +18
-0+{ +return NULL ; +} + +static void airoha_mac_config (struct phylink_config *config, +unsigned int mode, +const struct phylink_link_state *state) +{ +} +static int airoha_metadata_dst_alloc (struct airoha_gdm_port *port) {int i;@@ -2857,6 +2873,57 @@ bool airoha_is_valid_gdm_port(struct airoha_eth *eth,return false; } +static void airoha_mac_link_up (struct phylink_config *config, +struct phy_device *phy,unsigned int mode, +phy_interface_t interface,int speed, +int duplex,bool tx_pause,bool rx_pause) +{ +} + +static void airoha_mac_link_down(struct phylink_config *config,
drivers/net/ethernet/airoha/airoha_eth.c bool airoha_is_valid_gdm_port(struct airoha_eth *eth, · line 2893
Quoted 10 lines
drivers/net/ethernet/airoha/airoha_eth.c +10
-0+ unsigned int mode, phy_interface_t interface) +{ +} + +static const struct phylink_mac_ops airoha_phylink_ops = { + .mac_select_pcs = airoha_phylink_mac_select_pcs, + .mac_config = airoha_mac_config, + .mac_link_up = airoha_mac_link_up, + .mac_link_down = airoha_mac_link_down, +};
can you please align it like airoha_ethtool_ops or airoha_netdev_ops?
Quoted 89 lines
drivers/net/ethernet/airoha/airoha_eth.c +42
-1+ +static int airoha_setup_phylink (struct net_device *netdev) +{ +struct airoha_gdm_port *port =netdev_priv (netdev); +struct device *dev = &netdev->dev; +struct phylink *phylink; +int phy_mode; + + phy_mode =device_get_phy_mode (dev); +if (phy_mode <0 ) { +dev_err (dev,"incorrect phy-mode\n" ); +return phy_mode; + } + + port->phylink_config.dev = dev; + port->phylink_config.type =PHYLINK_NETDEV ; + port->phylink_config.mac_capabilities =MAC_ASYM_PAUSE | +MAC_SYM_PAUSE | +MAC_10000FD ; + +__set_bit (PHY_INTERFACE_MODE_INTERNAL , + port->phylink_config.supported_interfaces); + + phylink =phylink_create (&port->phylink_config,dev_fwnode (dev), + phy_mode, &airoha_phylink_ops); +if (IS_ERR (phylink)) +return PTR_ERR (phylink); + + port->phylink = phylink; + +return 0 ; +} +static int airoha_alloc_gdm_port (struct airoha_eth *eth,struct device_node *np,int index) {@@ -2935,12 +3002,18 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth,if (err)return err; - err =register_netdev (dev); + err =airoha_setup_phylink (port->dev);if (err) goto free_metadata_dst; + err =register_netdev (dev); +if (err) + goto free_phylink; +return 0 ; +free_phylink: +phylink_destroy (port->phylink); free_metadata_dst:airoha_metadata_dst_free (port);return err;@@ -3049,6 +3122,7 @@ static int airoha_probe(struct platform_device *pdev)if (port && port->dev->reg_state ==NETREG_REGISTERED ) {unregister_netdev (port->dev); +phylink_destroy (port->phylink);airoha_metadata_dst_free (port); } }@@ -3076,6 +3150,7 @@ static void airoha_remove(struct platform_device *pdev)airoha_dev_stop (port->dev);unregister_netdev (port->dev); +phylink_destroy (port->phylink);airoha_metadata_dst_free (port); }free_netdev (eth->napi_dev);drivers/net/ethernet/airoha/airoha_eth.h +3
-0@@ -531,6 +531,9 @@ struct airoha_gdm_port {struct net_device *dev;int id; +struct phylink *phylink; +struct phylink_config phylink_config; +struct airoha_hw_stats stats;DECLARE_BITMAP (qos_sq_bmap,AIROHA_NUM_QOS_CHANNELS );Signature · 1 line
2.51.0
Re: [net-next PATCH v2 2/2] net: airoha: add phylink support for GDM1
In reply to Christian MarangiQuoted 18 lines · Christian Marangi
In preparation for support of GDM2+ port, fill in phylink OPs for GDM1 that is an INTERNAL port for the Embedded Switch.
Add all the phylink start/stop and fill in the MAC capabilities and the internal interface as the supported interface.
Signed-off-by Christian Marangi <[email protected]>--- drivers/net/ethernet/airoha/Kconfig | 1 + drivers/net/ethernet/airoha/airoha_eth.c | 77 +++++++++++++++++++++++- drivers/net/ethernet/airoha/airoha_eth.h | 3 + 3 files changed, 80 insertions(+), 1 deletion(-)drivers/net/ethernet/airoha/Kconfig +0
-0
drivers/net/ethernet/airoha/Kconfig line 5
Quoted 4 lines
drivers/net/ethernet/airoha/Kconfig +1
-0@@ -2,6 +2,7 @@ config NET_VENDOR_AIROHA bool "Airoha devices" depends on ARCH_AIROHA || COMPILE_TEST + select PHYLIB
This looks wrong if you're using phylink.
Quoted 8 lines
drivers/net/ethernet/airoha/Kconfig +0
-0help If you have a Airoha SoC with ethernet, say Y.drivers/net/ethernet/airoha/airoha_eth.c +0
-0
drivers/net/ethernet/airoha/airoha_eth.c static int airoha_dev_open(struct net_device *dev) · line 1620
Quoted 8 lines
drivers/net/ethernet/airoha/airoha_eth.c +2
-0@@ -1613,6 +1613,8 @@ static int airoha_dev_open(struct net_device *dev)struct airoha_gdm_port *port =netdev_priv (dev);struct airoha_qdma *qdma = port->qdma; +phylink_start (port->phylink); +netif_tx_start_all_queues (dev); err =airoha_set_vip_for_gdm_port (port, true);if (err)
phylink_start() _can_ bring the carrier up immediately. Is the netdev ready to start operating at the point phylink_start() has been called? This error handling suggests the answer is "no", and the lack of phylink_stop() in the error path is also a red flag.
Quoted 10 lines
drivers/net/ethernet/airoha/airoha_eth.c +2
-0@@ -1665,6 +1667,8 @@ static int airoha_dev_stop(struct net_device *dev) } } +phylink_stop (port->phylink); +return 0 ; }
drivers/net/ethernet/airoha/airoha_eth.c static const struct ethtool_ops airoha_ethtool_ops = { · line 2821
Quoted 5 lines
drivers/net/ethernet/airoha/airoha_eth.c +2
-0@@ -2813,6 +2817,18 @@ static const struct ethtool_ops airoha_ethtool_ops = { .get_link = ethtool_op_get_link, }; +static struct phylink_pcs *airoha_phylink_mac_select_pcs (struct phylink_config *config, +phy_interface_t interface)
I'd write this as:
static struct phylink_pcs * airoha_phylink_mac_select_pcs(struct phylink_config *config,
phy_interface_t interface)
but:
drivers/net/ethernet/airoha/airoha_eth.c static const struct ethtool_ops airoha_ethtool_ops = { · line 2824
Quoted 3 lines
drivers/net/ethernet/airoha/airoha_eth.c +3
-0+{ +return NULL ; +}
Not sure what the point of this is, as this will be the effect if this function is not provided.
Quoted 22 lines
drivers/net/ethernet/airoha/airoha_eth.c +15
-0+ +static void airoha_mac_config (struct phylink_config *config, +unsigned int mode, +const struct phylink_link_state *state) +{ +} +static int airoha_metadata_dst_alloc (struct airoha_gdm_port *port) {int i;@@ -2857,6 +2873,57 @@ bool airoha_is_valid_gdm_port(struct airoha_eth *eth,return false; } +static void airoha_mac_link_up (struct phylink_config *config, +struct phy_device *phy,unsigned int mode, +phy_interface_t interface,int speed, +int duplex,bool tx_pause,bool rx_pause) +{ +} + +static void airoha_mac_link_down(struct phylink_config *config,
drivers/net/ethernet/airoha/airoha_eth.c bool airoha_is_valid_gdm_port(struct airoha_eth *eth, · line 2893
Quoted 10 lines
drivers/net/ethernet/airoha/airoha_eth.c +10
-0+ unsigned int mode, phy_interface_t interface) +{ +} + +static const struct phylink_mac_ops airoha_phylink_ops = { + .mac_select_pcs = airoha_phylink_mac_select_pcs, + .mac_config = airoha_mac_config, + .mac_link_up = airoha_mac_link_up, + .mac_link_down = airoha_mac_link_down, +};
All the called methods are entirely empty, meaning that anything that phylink reports may not reflect what is going on with the device.
Is there a plan to implement these methods?
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [net-next PATCH v2 2/2] net: airoha: add phylink support for GDM1
Quoted 37 lines · Russell King (Oracle)
Quoted 18 lines · Christian Marangi
In preparation for support of GDM2+ port, fill in phylink OPs for GDM1 that is an INTERNAL port for the Embedded Switch.
Add all the phylink start/stop and fill in the MAC capabilities and the internal interface as the supported interface.
Signed-off-by Christian Marangi <[email protected]>--- drivers/net/ethernet/airoha/Kconfig | 1 + drivers/net/ethernet/airoha/airoha_eth.c | 77 +++++++++++++++++++++++- drivers/net/ethernet/airoha/airoha_eth.h | 3 + 3 files changed, 80 insertions(+), 1 deletion(-)drivers/net/ethernet/airoha/Kconfig +0
-0drivers/net/ethernet/airoha/Kconfig line 5
Quoted 4 lines
drivers/net/ethernet/airoha/Kconfig +1
-0@@ -2,6 +2,7 @@ config NET_VENDOR_AIROHA bool "Airoha devices" depends on ARCH_AIROHA || COMPILE_TEST + select PHYLIBThis looks wrong if you're using phylink.
Quoted 11 lines
drivers/net/ethernet/airoha/Kconfig +0
-0help If you have a Airoha SoC with ethernet, say Y.drivers/net/ethernet/airoha/airoha_eth.c +0
-0@@ -1613,6 +1613,8 @@ static int airoha_dev_open(struct net_device *dev)struct airoha_gdm_port *port =netdev_priv (dev);struct airoha_qdma *qdma = port->qdma;
Quoted 11 lines
drivers/net/ethernet/airoha/airoha_eth.c static int airoha_dev_open(struct net_device *dev) · line 1620
Quoted 5 lines
drivers/net/ethernet/airoha/airoha_eth.c +2
-0+phylink_start (port->phylink); +netif_tx_start_all_queues (dev); err =airoha_set_vip_for_gdm_port (port, true);if (err)
phylink_start()_can_ bring the carrier up immediately. Is the netdev ready to start operating at the pointphylink_start()has been called? This error handling suggests the answer is "no", and the lack ofphylink_stop()in the error path is also a red flag.
So I guess the correct way is to move start at the very end of dev_open.
Quoted 22 lines
Quoted 10 lines
drivers/net/ethernet/airoha/airoha_eth.c +2
-0@@ -1665,6 +1667,8 @@ static int airoha_dev_stop(struct net_device *dev) } } +phylink_stop (port->phylink); +return 0 ; }drivers/net/ethernet/airoha/airoha_eth.c static const struct ethtool_ops airoha_ethtool_ops = { · line 2821
Quoted 5 lines
drivers/net/ethernet/airoha/airoha_eth.c +2
-0@@ -2813,6 +2817,18 @@ static const struct ethtool_ops airoha_ethtool_ops = { .get_link = ethtool_op_get_link, }; +static struct phylink_pcs *airoha_phylink_mac_select_pcs (struct phylink_config *config, +phy_interface_t interface)I'd write this as:
static struct
phylink_pcs* airoha_phylink_mac_select_pcs(structphylink_config*config,
phy_interface_tinterface)
Quoted 9 lines
but:
drivers/net/ethernet/airoha/airoha_eth.c static const struct ethtool_ops airoha_ethtool_ops = { · line 2824
Quoted 3 lines
drivers/net/ethernet/airoha/airoha_eth.c +3
-0+{ +return NULL ; +}Not sure what the point of this is, as this will be the effect if this function is not provided.
Sorry I was confused with the other OPs that are mandatory or a kernel panic is triggered if not defined. (for example the MAC config)
Quoted 36 lines
Quoted 22 lines
drivers/net/ethernet/airoha/airoha_eth.c +15
-0+ +static void airoha_mac_config (struct phylink_config *config, +unsigned int mode, +const struct phylink_link_state *state) +{ +} +static int airoha_metadata_dst_alloc (struct airoha_gdm_port *port) {int i;@@ -2857,6 +2873,57 @@ bool airoha_is_valid_gdm_port(struct airoha_eth *eth,return false; } +static void airoha_mac_link_up (struct phylink_config *config, +struct phy_device *phy,unsigned int mode, +phy_interface_t interface,int speed, +int duplex,bool tx_pause,bool rx_pause) +{ +} + +static void airoha_mac_link_down(struct phylink_config *config,drivers/net/ethernet/airoha/airoha_eth.c bool airoha_is_valid_gdm_port(struct airoha_eth *eth, · line 2893
Quoted 10 lines
drivers/net/ethernet/airoha/airoha_eth.c +10
-0+ unsigned int mode, phy_interface_t interface) +{ +} + +static const struct phylink_mac_ops airoha_phylink_ops = { + .mac_select_pcs = airoha_phylink_mac_select_pcs, + .mac_config = airoha_mac_config, + .mac_link_up = airoha_mac_link_up, + .mac_link_down = airoha_mac_link_down, +};All the called methods are entirely empty, meaning that anything that phylink reports may not reflect what is going on with the device.
Quoted 2 lines
Is there a plan to implement these methods?
Yes. For the internal port there isn't much to configure but when the PCS for the other GDM port will be implemented, those will be filled in. This is really to implement the generic part and prevent having a massive series later (as it will be already quite big and if not more than 10-12 patch)
Hope it's understandable why all these empty functions.
Signature · 1 line
Ansuel