* [PATCH 0/1] net: dsa: b53: mmap: add dsa switch ops
@ 2023-03-23 17:02 Álvaro Fernández Rojas
2023-03-23 17:02 ` [PATCH 1/1] " Álvaro Fernández Rojas
2023-03-23 18:19 ` [PATCH 0/1] " Florian Fainelli
0 siblings, 2 replies; 5+ messages in thread
From: Álvaro Fernández Rojas @ 2023-03-23 17:02 UTC (permalink / raw)
To: f.fainelli, jonas.gorski, andrew, olteanv, davem, edumazet, kuba,
pabeni, linux, netdev, linux-kernel
Cc: Álvaro Fernández Rojas
B53 MMAP switches have a MDIO Mux bus controller which should be used instead
of the default phy_read/phy_write ops used in the rest of the B53 controllers.
Therefore, in order to use the proper MDIO Mux bus controller we need to
replicate the default B53 DSA switch ops removing the phy_read/phy_write
entries.
Without this, when external switches are configured together with B53 MMAP
internal switches the device will hang on phy_read/phy_write ops.
This is an alternative to:
- https://patchwork.kernel.org/project/netdevbpf/cover/20230317113427.302162-1-noltari@gmail.com/
- https://patchwork.kernel.org/project/netdevbpf/patch/20230317113427.302162-2-noltari@gmail.com/
- https://patchwork.kernel.org/project/netdevbpf/patch/20230317113427.302162-3-noltari@gmail.com/
- https://patchwork.kernel.org/project/netdevbpf/patch/20230317113427.302162-4-noltari@gmail.com/
As discussed, it was an ABI break and not the correct way of fixing the issue.
And also to:
- https://patchwork.kernel.org/project/netdevbpf/patch/20230320182813.963508-1-noltari@gmail.com/
Álvaro Fernández Rojas (1):
net: dsa: b53: mmap: add dsa switch ops
drivers/net/dsa/b53/b53_common.c | 22 +++++++++---------
drivers/net/dsa/b53/b53_mmap.c | 40 ++++++++++++++++++++++++++++++++
drivers/net/dsa/b53/b53_priv.h | 11 +++++++++
3 files changed, 62 insertions(+), 11 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] net: dsa: b53: mmap: add dsa switch ops
2023-03-23 17:02 [PATCH 0/1] net: dsa: b53: mmap: add dsa switch ops Álvaro Fernández Rojas
@ 2023-03-23 17:02 ` Álvaro Fernández Rojas
2023-03-23 18:19 ` [PATCH 0/1] " Florian Fainelli
1 sibling, 0 replies; 5+ messages in thread
From: Álvaro Fernández Rojas @ 2023-03-23 17:02 UTC (permalink / raw)
To: f.fainelli, jonas.gorski, andrew, olteanv, davem, edumazet, kuba,
pabeni, linux, netdev, linux-kernel
Cc: Álvaro Fernández Rojas
B53 MMAP switches have a MDIO Mux bus controller which should be used instead
of the default phy_read/phy_write ops used in the rest of the B53 controllers.
Therefore, in order to use the proper MDIO Mux bus controller we need to
replicate the default B53 DSA switch ops removing the phy_read/phy_write
entries.
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
drivers/net/dsa/b53/b53_common.c | 22 +++++++++---------
drivers/net/dsa/b53/b53_mmap.c | 40 ++++++++++++++++++++++++++++++++
drivers/net/dsa/b53/b53_priv.h | 11 +++++++++
3 files changed, 62 insertions(+), 11 deletions(-)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 1f9b251a5452..9080506f2a9c 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1096,7 +1096,7 @@ int b53_setup_devlink_resources(struct dsa_switch *ds)
}
EXPORT_SYMBOL(b53_setup_devlink_resources);
-static int b53_setup(struct dsa_switch *ds)
+int b53_setup(struct dsa_switch *ds)
{
struct b53_device *dev = ds->priv;
unsigned int port;
@@ -1134,7 +1134,7 @@ static int b53_setup(struct dsa_switch *ds)
return b53_setup_devlink_resources(ds);
}
-static void b53_teardown(struct dsa_switch *ds)
+void b53_teardown(struct dsa_switch *ds)
{
dsa_devlink_resources_unregister(ds);
}
@@ -1253,8 +1253,8 @@ static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port,
phy_modes(interface));
}
-static void b53_adjust_link(struct dsa_switch *ds, int port,
- struct phy_device *phydev)
+void b53_adjust_link(struct dsa_switch *ds, int port,
+ struct phy_device *phydev)
{
struct b53_device *dev = ds->priv;
struct ethtool_eee *p = &dev->ports[port].eee;
@@ -1356,8 +1356,8 @@ void b53_port_event(struct dsa_switch *ds, int port)
}
EXPORT_SYMBOL(b53_port_event);
-static void b53_phylink_get_caps(struct dsa_switch *ds, int port,
- struct phylink_config *config)
+void b53_phylink_get_caps(struct dsa_switch *ds, int port,
+ struct phylink_config *config)
{
struct b53_device *dev = ds->priv;
@@ -1401,9 +1401,9 @@ static void b53_phylink_get_caps(struct dsa_switch *ds, int port,
config->legacy_pre_march2020 = false;
}
-static struct phylink_pcs *b53_phylink_mac_select_pcs(struct dsa_switch *ds,
- int port,
- phy_interface_t interface)
+struct phylink_pcs *b53_phylink_mac_select_pcs(struct dsa_switch *ds,
+ int port,
+ phy_interface_t interface)
{
struct b53_device *dev = ds->priv;
@@ -2262,7 +2262,7 @@ int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e)
}
EXPORT_SYMBOL(b53_set_mac_eee);
-static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
+int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
{
struct b53_device *dev = ds->priv;
bool enable_jumbo;
@@ -2277,7 +2277,7 @@ static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
return b53_set_jumbo(dev, enable_jumbo, allow_10_100);
}
-static int b53_get_max_mtu(struct dsa_switch *ds, int port)
+int b53_get_max_mtu(struct dsa_switch *ds, int port)
{
return JMS_MAX_SIZE;
}
diff --git a/drivers/net/dsa/b53/b53_mmap.c b/drivers/net/dsa/b53/b53_mmap.c
index 7bb774368f64..45481db7a891 100644
--- a/drivers/net/dsa/b53/b53_mmap.c
+++ b/drivers/net/dsa/b53/b53_mmap.c
@@ -22,6 +22,7 @@
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/platform_data/b53.h>
+#include <net/dsa.h>
#include "b53_priv.h"
@@ -29,6 +30,44 @@ struct b53_mmap_priv {
void __iomem *regs;
};
+static const struct dsa_switch_ops b53_mmap_switch_ops = {
+ .get_tag_protocol = b53_get_tag_protocol,
+ .setup = b53_setup,
+ .teardown = b53_teardown,
+ .get_strings = b53_get_strings,
+ .get_ethtool_stats = b53_get_ethtool_stats,
+ .get_sset_count = b53_get_sset_count,
+ .get_ethtool_phy_stats = b53_get_ethtool_phy_stats,
+ .adjust_link = b53_adjust_link,
+ .phylink_get_caps = b53_phylink_get_caps,
+ .phylink_mac_select_pcs = b53_phylink_mac_select_pcs,
+ .phylink_mac_config = b53_phylink_mac_config,
+ .phylink_mac_link_down = b53_phylink_mac_link_down,
+ .phylink_mac_link_up = b53_phylink_mac_link_up,
+ .port_enable = b53_enable_port,
+ .port_disable = b53_disable_port,
+ .get_mac_eee = b53_get_mac_eee,
+ .set_mac_eee = b53_set_mac_eee,
+ .port_bridge_join = b53_br_join,
+ .port_bridge_leave = b53_br_leave,
+ .port_pre_bridge_flags = b53_br_flags_pre,
+ .port_bridge_flags = b53_br_flags,
+ .port_stp_state_set = b53_br_set_stp_state,
+ .port_fast_age = b53_br_fast_age,
+ .port_vlan_filtering = b53_vlan_filtering,
+ .port_vlan_add = b53_vlan_add,
+ .port_vlan_del = b53_vlan_del,
+ .port_fdb_dump = b53_fdb_dump,
+ .port_fdb_add = b53_fdb_add,
+ .port_fdb_del = b53_fdb_del,
+ .port_mirror_add = b53_mirror_add,
+ .port_mirror_del = b53_mirror_del,
+ .port_mdb_add = b53_mdb_add,
+ .port_mdb_del = b53_mdb_del,
+ .port_max_mtu = b53_get_max_mtu,
+ .port_change_mtu = b53_change_mtu,
+};
+
static int b53_mmap_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val)
{
struct b53_mmap_priv *priv = dev->priv;
@@ -302,6 +341,7 @@ static int b53_mmap_probe(struct platform_device *pdev)
if (!dev)
return -ENOMEM;
+ dev->ds->ops = &b53_mmap_switch_ops;
dev->pdata = pdata;
platform_set_drvdata(pdev, dev);
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index a689a6950189..cd759b177c94 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -348,7 +348,16 @@ int b53_br_flags(struct dsa_switch *ds, int port,
struct switchdev_brport_flags flags,
struct netlink_ext_ack *extack);
int b53_setup_devlink_resources(struct dsa_switch *ds);
+int b53_setup(struct dsa_switch *ds);
+void b53_teardown(struct dsa_switch *ds);
+void b53_adjust_link(struct dsa_switch *ds, int port,
+ struct phy_device *phydev);
void b53_port_event(struct dsa_switch *ds, int port);
+void b53_phylink_get_caps(struct dsa_switch *ds, int port,
+ struct phylink_config *config);
+struct phylink_pcs *b53_phylink_mac_select_pcs(struct dsa_switch *ds,
+ int port,
+ phy_interface_t interface);
void b53_phylink_mac_config(struct dsa_switch *ds, int port,
unsigned int mode,
const struct phylink_link_state *state);
@@ -396,5 +405,7 @@ void b53_eee_enable_set(struct dsa_switch *ds, int port, bool enable);
int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy);
int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e);
int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e);
+int b53_change_mtu(struct dsa_switch *ds, int port, int mtu);
+int b53_get_max_mtu(struct dsa_switch *ds, int port);
#endif
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/1] net: dsa: b53: mmap: add dsa switch ops
2023-03-23 17:02 [PATCH 0/1] net: dsa: b53: mmap: add dsa switch ops Álvaro Fernández Rojas
2023-03-23 17:02 ` [PATCH 1/1] " Álvaro Fernández Rojas
@ 2023-03-23 18:19 ` Florian Fainelli
2023-03-23 19:42 ` Álvaro Fernández Rojas
1 sibling, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2023-03-23 18:19 UTC (permalink / raw)
To: Álvaro Fernández Rojas, jonas.gorski, andrew, olteanv,
davem, edumazet, kuba, pabeni, linux, netdev, linux-kernel
On 3/23/23 10:02, Álvaro Fernández Rojas wrote:
> B53 MMAP switches have a MDIO Mux bus controller which should be used instead
> of the default phy_read/phy_write ops used in the rest of the B53 controllers.
> Therefore, in order to use the proper MDIO Mux bus controller we need to
> replicate the default B53 DSA switch ops removing the phy_read/phy_write
> entries.
Did you try to implement b53_mmap_ops::phy_read16/phy_write16 and have
them return -EIO such that you do not fallback to the else path:
ret = b53_read16(priv, B53_PORT_MII_PAGE(addr),
reg * 2, &value);
The reason for the hang I believe is because the B53_PORT_MII_PAGE is
simply not mapped into the switch register space, and there is no logic
within the switch block to return an error when you read at that invalid
location.
Re-implementing dsa_switch_ops is usually done when you have a very
different switch integration logic, ala bcm_sf2, here it seems a bit of
a tall order for simply not using the phy_read16/phy_write16 functions.
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/1] net: dsa: b53: mmap: add dsa switch ops
2023-03-23 18:19 ` [PATCH 0/1] " Florian Fainelli
@ 2023-03-23 19:42 ` Álvaro Fernández Rojas
2023-03-23 19:45 ` Florian Fainelli
0 siblings, 1 reply; 5+ messages in thread
From: Álvaro Fernández Rojas @ 2023-03-23 19:42 UTC (permalink / raw)
To: Florian Fainelli
Cc: jonas.gorski, andrew, olteanv, davem, edumazet, kuba, pabeni,
linux, netdev, linux-kernel
El jue, 23 mar 2023 a las 19:19, Florian Fainelli
(<f.fainelli@gmail.com>) escribió:
>
> On 3/23/23 10:02, Álvaro Fernández Rojas wrote:
> > B53 MMAP switches have a MDIO Mux bus controller which should be used instead
> > of the default phy_read/phy_write ops used in the rest of the B53 controllers.
> > Therefore, in order to use the proper MDIO Mux bus controller we need to
> > replicate the default B53 DSA switch ops removing the phy_read/phy_write
> > entries.
>
> Did you try to implement b53_mmap_ops::phy_read16/phy_write16 and have
> them return -EIO such that you do not fallback to the else path:
Actually I tried -EINVAL and it didn't work, but I've just tried -EIO
and it works!
Many thanks for the suggestion!
I will send another patch adding phy_read/write ops and returning
-EIO, so please ignore this patch and sorry for the noise, but it took
a while until we reached a good solution for this :(...
>
> ret = b53_read16(priv, B53_PORT_MII_PAGE(addr),
> reg * 2, &value);
>
> The reason for the hang I believe is because the B53_PORT_MII_PAGE is
> simply not mapped into the switch register space, and there is no logic
> within the switch block to return an error when you read at that invalid
> location.
>
> Re-implementing dsa_switch_ops is usually done when you have a very
> different switch integration logic, ala bcm_sf2, here it seems a bit of
> a tall order for simply not using the phy_read16/phy_write16 functions.
> --
> Florian
>
--
Álvaro
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/1] net: dsa: b53: mmap: add dsa switch ops
2023-03-23 19:42 ` Álvaro Fernández Rojas
@ 2023-03-23 19:45 ` Florian Fainelli
0 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2023-03-23 19:45 UTC (permalink / raw)
To: Álvaro Fernández Rojas
Cc: jonas.gorski, andrew, olteanv, davem, edumazet, kuba, pabeni,
linux, netdev, linux-kernel
On 3/23/23 12:42, Álvaro Fernández Rojas wrote:
> El jue, 23 mar 2023 a las 19:19, Florian Fainelli
> (<f.fainelli@gmail.com>) escribió:
>>
>> On 3/23/23 10:02, Álvaro Fernández Rojas wrote:
>>> B53 MMAP switches have a MDIO Mux bus controller which should be used instead
>>> of the default phy_read/phy_write ops used in the rest of the B53 controllers.
>>> Therefore, in order to use the proper MDIO Mux bus controller we need to
>>> replicate the default B53 DSA switch ops removing the phy_read/phy_write
>>> entries.
>>
>> Did you try to implement b53_mmap_ops::phy_read16/phy_write16 and have
>> them return -EIO such that you do not fallback to the else path:
>
> Actually I tried -EINVAL and it didn't work, but I've just tried -EIO
> and it works!
> Many thanks for the suggestion!
>
> I will send another patch adding phy_read/write ops and returning
> -EIO, so please ignore this patch and sorry for the noise, but it took
> a while until we reached a good solution for this :(...
No worries, -EIO works because it is treated specially through the PHY
library to indicate a read error occurred, whereas the other return
codes do not necessarily produce that effect.
Thanks for your persistence!
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-23 19:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-23 17:02 [PATCH 0/1] net: dsa: b53: mmap: add dsa switch ops Álvaro Fernández Rojas
2023-03-23 17:02 ` [PATCH 1/1] " Álvaro Fernández Rojas
2023-03-23 18:19 ` [PATCH 0/1] " Florian Fainelli
2023-03-23 19:42 ` Álvaro Fernández Rojas
2023-03-23 19:45 ` Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).