Message ID | 20211006223603.18858-10-ansuelsmth@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Multiple improvement for qca8337 switch | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Series has a cover letter |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 7 of 7 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | No Fixes tag |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 21 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | No static functions without inline keyword in header files |
On Thu, Oct 07, 2021 at 12:35:59AM +0200, Ansuel Smith wrote: > Port 0 can be exchanged with port6. Handle this special case by also > checking the port6 if present. This is messy. The DSA core has no idea the ports have been swapped, so the interface names are going to be taken from DT unswaped. Now you appear to be taking phy-mode from the other port in DT. That is inconsistent. All the configuration for a port should come from the same place, nothing gets swapped. Or everything needs to swap, which means you need to change the DSA core. Andrew
On Thu, Oct 07, 2021 at 02:24:08AM +0200, Andrew Lunn wrote: > On Thu, Oct 07, 2021 at 12:35:59AM +0200, Ansuel Smith wrote: > > Port 0 can be exchanged with port6. Handle this special case by also > > checking the port6 if present. > > This is messy. > > The DSA core has no idea the ports have been swapped, so the interface > names are going to be taken from DT unswaped. Now you appear to be > taking phy-mode from the other port in DT. That is inconsistent. All > the configuration for a port should come from the same place, nothing > gets swapped. Or everything needs to swap, which means you need to > change the DSA core. > > Andrew The swap is internal. So from the dts side we still use port0 as port0, it's just swapped internally in the switch. The change here is required as this scan the rgmii delay and sets the value to be set later in the phylink mac config. We currently assume that only one cpu port is supported and that can be sgmii or rgmii. This specific switch have 2 cpu port and we can have one config with cpu port0 set to sgmii and cpu port6 set to rgmii-id. This patch is to address this and to add the delay function to scan also for the secondary cpu port. (again the real value will be set in the mac config function) Honestly i think we should just rework this and move the delay logic directly in the mac_config function and scan there directly. What do you think? That way we should be able to generalize this and drop the extra if.
On 10/7/21 6:31 AM, Ansuel Smith wrote: > On Thu, Oct 07, 2021 at 02:24:08AM +0200, Andrew Lunn wrote: >> On Thu, Oct 07, 2021 at 12:35:59AM +0200, Ansuel Smith wrote: >>> Port 0 can be exchanged with port6. Handle this special case by also >>> checking the port6 if present. >> >> This is messy. >> >> The DSA core has no idea the ports have been swapped, so the interface >> names are going to be taken from DT unswaped. Now you appear to be >> taking phy-mode from the other port in DT. That is inconsistent. All >> the configuration for a port should come from the same place, nothing >> gets swapped. Or everything needs to swap, which means you need to >> change the DSA core. >> >> Andrew > > The swap is internal. So from the dts side we still use port0 as port0, > it's just swapped internally in the switch. > The change here is required as this scan the rgmii delay and sets the > value to be set later in the phylink mac config. > We currently assume that only one cpu port is supported and that can be > sgmii or rgmii. This specific switch have 2 cpu port and we can have one > config with cpu port0 set to sgmii and cpu port6 set to rgmii-id. > This patch is to address this and to add the delay function to scan also > for the secondary cpu port. (again the real value will be set in the mac > config function) > Honestly i think we should just rework this and move the delay logic > directly in the mac_config function and scan there directly. What do you > think? That way we should be able to generalize this and drop the extra > if. Agreed, the whole port swapping business is really hairy and seems like it will led to unpleasant surprises down the road.
diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 3a040a3ed58e..4d4f23f7f948 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -906,7 +906,20 @@ qca8k_setup_of_rgmii_delay(struct qca8k_priv *priv) if (mode != PHY_INTERFACE_MODE_RGMII_ID && mode != PHY_INTERFACE_MODE_RGMII_RXID && mode != PHY_INTERFACE_MODE_RGMII_TXID) { - return 0; + /* Port 0 can be exchanged with port 6 */ + dp = dsa_to_port(priv->ds, 6); + if (!dp) + return 0; + + port_dn = dp->dn; + + /* Check if port 6 is set to the correct type */ + of_get_phy_mode(port_dn, &mode); + if (mode != PHY_INTERFACE_MODE_RGMII_ID && + mode != PHY_INTERFACE_MODE_RGMII_RXID && + mode != PHY_INTERFACE_MODE_RGMII_TXID) { + return 0; + } } switch (mode) {
Port 0 can be exchanged with port6. Handle this special case by also checking the port6 if present. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> --- drivers/net/dsa/qca8k.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)