net: stmmac: convert stmmac "pcs" to phylink
Subsystems (7)
v4 cover net: stmmac: convert stmmac "pcs" to phylink
Hi,
Changes since version 3:
- added Andrew's reviewed-bys
- fixed kernel-doc for dwmac_pcs_isr()
- updated patch 11 commit message
- fixed build error reported by Jakub
- add Sneh Shah to Cc list (for testing 2.5G modes)
Bartosz - I know you've given your tested-by this morning, I will be adding that after posting this series, so please don't think it's been lost!
Previous cover messages from earlier posts below:
This is version 3 of the series switching stmmac to use phylink PCS isntead of going behind phylink's back.
Changes since version 2:
- Adopted some of Serge's feedback.
- New patch: adding ethqos_pcs_set_inband() for qcom-ethqos so we have one place to modify for AN control rather than many.
- New patch: pass the stmmac_priv structure into the pcs_set_ane() method.
- New patch: remove pcs_get_adv_lp() early, as this is only for TBI and RTBI, support for which we dropped in an already merged patch.
- Provide stmmac_pcs structure to encapsulate the pointer to stmmac_priv, PCS MMIO address pointer and phylink_pcs structure.
- Restructure dwmac_pcs_config() so we can eventually share code with dwmac_ctrl_ane().
- New patch: move dwmac_ctrl_ane() into stmmac_pcs.c, and share code.
- New patch: pass the stmmac_pcs structure into dwmac_pcs_isr().
- New patch: similar to Serge's patch, rename the PCS registers, but use STMMAC_PCS_ as the prefix rather than just PCS_ which is too generic.
- New patch: incorporate "net: stmmac: Activate Inband/PCS flag based on the selected iface" from Serge.
On the subject of whether we should have two PCS instances, I experimented with that and have now decided against it. Instead, dwmac_pcs_config() now tests whether we need to fiddle with the PCS control register or not.
Note that I prefer not to have multiple layers of indirection, but instead prefer a library-style approach, which is why I haven't turned the PCS support into something that's self contained with a method in the MAC driver to grab the RGSMII status.
-----
This is version 2 of the series switching stmmac to use phylink PCS instead of going behind phylink's back.
Changes since version 1:
- Addition of patches from Serge Semin to allow RGMII to use the "PCS" code even if priv->dma_cap.pcs is not set (including tweaks by me.)
- Restructuring of the patch set to be a more logical split.
- Leave the pcs_ctrl_ane methods until we've worked out what to do with the qcom-ethqos driver (this series may still end up breaking it, but at least we will now successfully compile.)
A reminder that what I want to hear from this patch set are the results of testing - and thanks to Serge, the RGMII paths were exercised, but I have not had any results for the SGMII side of this.
There are still a bunch of outstanding questions:
- whether we should be using two separate PCS instances, one for RGMII and another for SGMII. If the PCS hardware is not present, but are using RGMII mode, then we probably don't want to be accessing the registers that would've been there for SGMII.
- what the three interrupts associated with the PCS code actually mean when they fire.
- which block's status we're reading in the pcs_get_state() method, and whether we should be reading that for both RGMII and SGMII.
- whether we need to activate phylink's inband mode in more cases (so that the PCS/MAC status gets read and used for the link.)
There's probably more questions to be asked... but really the critical thing is to shake out any breakage from making this conversion. Bear in mind that I have little knowledge of this hardware, so this conversion has been done somewhat blind using only what I can observe from the current driver.
------
As I noted recently in a thread (and was ignored) stmmac sucks. (I won't hide my distain for drivers that make my life as phylink maintainer more difficult!)
One of the contract conditions for using phylink is that the driver will _not_ mess with the netif carrier. stmmac developers/maintainers clearly didn't read that, because stmmac messes with the netif carrier, which destroys phylink's guarantee that it'll make certain calls in a particular order (e.g. it won't call mac_link_up() twice in a row without an intervening mac_link_down().) This is clearly stated in the phylink documentation.
Thus, this patch set attempts to fix this. Why does it mess with the netif carrier? It has its own independent PCS implementation that completely bypasses phylink _while_ phylink is still being used. This is not acceptable. Either the driver uses phylink, or it doesn't use phylink. There is no half-way house about this. Therefore, this driver needs to either be fixed, or needs to stop using phylink.
Since I was ignored when I brought this up, I've hacked together the following patch set - and it is hacky at the moment. It's also broken because of recentl changes involving dwmac-qcom-ethqos.c - but there isn't sufficient information in the driver for me to fix this. The driver appears to use SGMII at 2500Mbps, which simply does not exist. What interface mode (and neg_mode) does phylink pass to pcs_config() in each of the speeds that dwmac-qcom-ethqos.c is interested in. Without this information, I can't do that conversion. So for the purposes of this, I've just ignored dwmac-qcom-ethqos.c (which means it will fail to build.)
The patch splitup is not ideal, but that's not what I'm interested in here. What I want to hear is the results of testing - does this switch of the RGMII/SGMII "pcs" stuff to a phylink_pcs work for this driver?
Please don't review the patches, but you are welcome to send fixes to them. Once we know that the overall implementation works, then I'll look at how best to split the patches. In the mean time, the present form is more convenient for making changes and fixing things.
There is still more improvement that's needed here.
Thanks.
drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +- drivers/net/ethernet/stmicro/stmmac/common.h | 25 ++-- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 13 +- drivers/net/ethernet/stmicro/stmmac/dwmac1000.h | 13 +- .../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 110 +++++++------- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 13 +- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 99 +++++++------ drivers/net/ethernet/stmicro/stmmac/hwif.h | 24 ++-- .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 111 +------------- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 30 +--- drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c | 63 ++++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h | 160 ++++++++++----------- 12 files changed, 306 insertions(+), 357 deletions(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
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!
RFC PATCH v4 1/14 net: stmmac: qcom-ethqos: add ethqos_pcs_set_inband()
Add ethqos_pcs_set_inband() to improve readability, and to allow future changes when phylink PCS support is properly merged.
--- .../net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +9 -4
@@ -636,6 +636,11 @@ static void ethqos_set_serdes_speed(struct qcom_ethqos *ethqos, int speed) } } +static void ethqos_pcs_set_inband (struct stmmac_priv *priv,bool enable) +{ +stmmac_pcs_ctrl_ane (priv, priv->ioaddr, enable,0 ,0 ); +} +/* On interface toggle MAC registers gets reset. * Configure MAC block for SGMII on ethernet phy link up */
@@ -654,7 +659,7 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos)RGMII_CONFIG2_RGMII_CLK_SEL_CFG , RGMII_IO_MACRO_CONFIG2);ethqos_set_serdes_speed (ethqos,SPEED_2500 ); -stmmac_pcs_ctrl_ane (priv, priv->ioaddr,0 ,0 ,0 ); +ethqos_pcs_set_inband (priv, false);break ;case SPEED_1000 : val &= ~ETHQOS_MAC_CTRL_PORT_SEL ;
@@ -662,12 +667,12 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos)RGMII_CONFIG2_RGMII_CLK_SEL_CFG , RGMII_IO_MACRO_CONFIG2);ethqos_set_serdes_speed (ethqos,SPEED_1000 ); -stmmac_pcs_ctrl_ane (priv, priv->ioaddr,1 ,0 ,0 ); +ethqos_pcs_set_inband (priv, true);break ;case SPEED_100 : val |=ETHQOS_MAC_CTRL_PORT_SEL |ETHQOS_MAC_CTRL_SPEED_MODE ;ethqos_set_serdes_speed (ethqos,SPEED_1000 ); -stmmac_pcs_ctrl_ane (priv, priv->ioaddr,1 ,0 ,0 ); +ethqos_pcs_set_inband (priv, true);break ;case SPEED_10 : val |=ETHQOS_MAC_CTRL_PORT_SEL ;
@@ -677,7 +682,7 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) SGMII_10M_RX_CLK_DVDR), RGMII_IO_MACRO_CONFIG);ethqos_set_serdes_speed (ethqos,SPEED_1000 ); -stmmac_pcs_ctrl_ane (priv, priv->ioaddr,1 ,0 ,0 ); +ethqos_pcs_set_inband (priv, true);break ; }
Signature · 1 line
2.30.2
RFC PATCH v4 2/14 net: stmmac: replace ioaddr with stmmac_priv for pcs_set_ane() method
In reply to Russell King (Oracle)Pass the stmmac_priv structure into the pcs_set_ane() MAC method rather than having callers dereferencing this structure for the IO address.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 6 +++--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 4 ++-- drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1 -1
@@ -638,7 +638,7 @@ static void ethqos_set_serdes_speed(struct qcom_ethqos *ethqos, int speed)static void ethqos_pcs_set_inband (struct stmmac_priv *priv,bool enable) { -stmmac_pcs_ctrl_ane (priv, priv->ioaddr, enable,0 ,0 ); +stmmac_pcs_ctrl_ane (priv, enable,0 ,0 ); }/* On interface toggle MAC registers gets reset.
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +3 -3
@@ -398,10 +398,10 @@ static void dwmac1000_set_eee_timer(struct mac_device_info *hw, int ls, int tw)writel (value, ioaddr +LPI_TIMER_CTRL ); } -static void dwmac1000_ctrl_ane (void __iomem *ioaddr,bool ane,bool srgmi_ral, -bool loopback) +static void dwmac1000_ctrl_ane (struct stmmac_priv *priv,bool ane, +bool srgmi_ral,bool loopback) { -dwmac_ctrl_ane (ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); +dwmac_ctrl_ane (priv->ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); }static void dwmac1000_get_adv_lp (void __iomem *ioaddr,struct rgmii_adv *adv)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +2 -2
@@ -752,10 +752,10 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, } } -static void dwmac4_ctrl_ane (void __iomem *ioaddr,bool ane,bool srgmi_ral, +static void dwmac4_ctrl_ane (struct stmmac_priv *priv,bool ane,bool srgmi_ral,bool loopback) { -dwmac_ctrl_ane (ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); +dwmac_ctrl_ane (priv->ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); }static void dwmac4_get_adv_lp (void __iomem *ioaddr,struct rgmii_adv *adv)
drivers/net/ethernet/stmicro/stmmac/hwif.h +2 -2
@@ -368,7 +368,7 @@ struct stmmac_ops { struct stmmac_extra_stats *x, u32 rx_queues, u32 tx_queues);/* PCS calls */ -void (*pcs_ctrl_ane)(void __iomem *ioaddr,bool ane,bool srgmi_ral, +void (*pcs_ctrl_ane)(struct stmmac_priv *priv,bool ane,bool srgmi_ral,bool loopback);void (*pcs_get_adv_lp)(void __iomem *ioaddr,struct rgmii_adv *adv);/* Safety Features */
@@ -482,7 +482,7 @@ struct stmmac_ops { #define stmmac_mac_debug(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, debug, __priv, __args) #define stmmac_pcs_ctrl_ane(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args) + stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __priv, __args) #define stmmac_pcs_get_adv_lp(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, pcs_get_adv_lp, __args) #define stmmac_safety_feat_config(__priv, __args...) \
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +1 -1
@@ -416,7 +416,7 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev,return -EINVAL ;mutex_lock (&priv->lock); -stmmac_pcs_ctrl_ane (priv, priv->ioaddr,1 , priv->hw->ps,0 ); +stmmac_pcs_ctrl_ane (priv,1 , priv->hw->ps,0 );mutex_unlock (&priv->lock);return 0 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -3487,7 +3487,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) }if (priv->hw->pcs) -stmmac_pcs_ctrl_ane (priv, priv->ioaddr,1 , priv->hw->ps,0 ); +stmmac_pcs_ctrl_ane (priv,1 , priv->hw->ps,0 );/* set TX and RX rings length */ stmmac_set_rings_length (priv);
Signature · 1 line
2.30.2
RFC PATCH v4 3/14 net: stmmac: remove pcs_get_adv_lp() support
In reply to Russell King (Oracle)Discussing with Serge Semin, it appears that the GMAC_ANE_ADV and GMAC_ANE_LPA registers are only available for TBI and RTBI PHY interfaces. In commit 482b3c3ba757 ("net: stmmac: Drop TBI/RTBI PCS flags") support for these was dropped, and thus it no longer makes sense to access these registers.
Remove the *_get_adv_lp() functions from the stmmac driver.
--- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 6 --- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 ---- drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 -- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 47 +------------------ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 32 +------------ 5 files changed, 4 insertions(+), 92 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +0 -6
@@ -404,11 +404,6 @@ static void dwmac1000_ctrl_ane(struct stmmac_priv *priv, bool ane,dwmac_ctrl_ane (priv->ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); } -static void dwmac1000_get_adv_lp (void __iomem *ioaddr,struct rgmii_adv *adv) -{ -dwmac_get_adv_lp (ioaddr,GMAC_PCS_BASE , adv); -} -static void dwmac1000_debug (struct stmmac_priv *priv,void __iomem *ioaddr,struct stmmac_extra_stats *x,u32 rx_queues,u32 tx_queues)
@@ -514,7 +509,6 @@ const struct stmmac_ops dwmac1000_ops = { .set_eee_pls = dwmac1000_set_eee_pls, .debug = dwmac1000_debug, .pcs_ctrl_ane = dwmac1000_ctrl_ane, - .pcs_get_adv_lp = dwmac1000_get_adv_lp, .set_mac_loopback = dwmac1000_set_mac_loopback, };
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +0 -8
@@ -758,11 +758,6 @@ static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral,dwmac_ctrl_ane (priv->ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); } -static void dwmac4_get_adv_lp (void __iomem *ioaddr,struct rgmii_adv *adv) -{ -dwmac_get_adv_lp (ioaddr,GMAC_PCS_BASE , adv); -} -/* RGMII or SMII interface */ static void dwmac4_phystatus (void __iomem *ioaddr,struct stmmac_extra_stats *x) {
@@ -1210,7 +1205,6 @@ const struct stmmac_ops dwmac4_ops = { .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, - .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .set_mac_loopback = dwmac4_set_mac_loopback,
@@ -1254,7 +1248,6 @@ const struct stmmac_ops dwmac410_ops = { .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, - .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .flex_pps_config = dwmac5_flex_pps_config,
@@ -1302,7 +1295,6 @@ const struct stmmac_ops dwmac510_ops = { .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, - .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .safety_feat_config = dwmac5_safety_feat_config,
drivers/net/ethernet/stmicro/stmmac/hwif.h +0 -3
@@ -370,7 +370,6 @@ struct stmmac_ops {/* PCS calls */ void (*pcs_ctrl_ane)(struct stmmac_priv *priv,bool ane,bool srgmi_ral,bool loopback); -void (*pcs_get_adv_lp)(void __iomem *ioaddr,struct rgmii_adv *adv);/* Safety Features */ int (*safety_feat_config)(void __iomem *ioaddr,unsigned int asp,struct stmmac_safety_feature_cfg *safety_cfg);
@@ -483,8 +482,6 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, debug, __priv, __args) #define stmmac_pcs_ctrl_ane(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __priv, __args) -#define stmmac_pcs_get_adv_lp(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, pcs_get_adv_lp, __args) #define stmmac_safety_feat_config(__priv, __args...) \ stmmac_do_callback(__priv, mac, safety_feat_config, __args) #define stmmac_safety_feat_irq_status(__priv, __args...) \
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +2 -45
87 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +2 -30
@@ -16,6 +16,8 @@/* PCS registers (AN/TBI/SGMII/RGMII) offsets */ #define GMAC_AN_CTRL (x) (x)/* AN control */ #define GMAC_AN_STATUS (x) (x + 0x4)/* AN status */ + +/* ADV, LPA and EXP are only available for the TBI and RTBI interfaces */ #define GMAC_ANE_ADV (x) (x + 0x8)/* ANE Advertisement */ #define GMAC_ANE_LPA (x) (x + 0xc)/* ANE link partener ability */ #define GMAC_ANE_EXP (x) (x + 0x10)/* ANE expansion */
@@ -107,34 +109,4 @@ static inline void dwmac_ctrl_ane(void __iomem *ioaddr, u32 reg, bool ane, writel(value, ioaddr + GMAC_AN_CTRL(reg)); } - -/** -* dwmac_get_adv_lp - Get ADV and LP cap -* @ioaddr: IO registers pointer -* @reg: Base address of the AN Control Register. -* @adv_lp: structure to store the adv,lp status -* Description: this is to expose the ANE advertisement and Link partner ability -* status to ethtool support. -*/ -static inline void dwmac_get_adv_lp (void __iomem *ioaddr,u32 reg, -struct rgmii_adv *adv_lp) -{ -u32 value =readl (ioaddr +GMAC_ANE_ADV (reg)); - -if (value &GMAC_ANE_FD ) - adv_lp->duplex =DUPLEX_FULL ; -if (value &GMAC_ANE_HD ) - adv_lp->duplex |=DUPLEX_HALF ; - - adv_lp->pause = (value &GMAC_ANE_PSE ) >>GMAC_ANE_PSE_SHIFT ; - - value =readl (ioaddr +GMAC_ANE_LPA (reg)); - -if (value &GMAC_ANE_FD ) - adv_lp->lp_duplex =DUPLEX_FULL ; -if (value &GMAC_ANE_HD ) - adv_lp->lp_duplex =DUPLEX_HALF ; - - adv_lp->lp_pause = (value &GMAC_ANE_PSE ) >>GMAC_ANE_PSE_SHIFT ; -}#endif /* __STMMAC_PCS_H__ */
Signature · 1 line
2.30.2
RFC PATCH v4 4/14 net: stmmac: add infrastructure for hwifs to provide PCS
In reply to Russell King (Oracle)Allow hwifs to provide a phylink_select_pcs() implementation via struct stmmac_ops, which can be used to provide a phylink PCS.
Code analysis shows that when STMMAC_FLAG_HAS_INTEGRATED_PCS is set, then:
stmmac_common_interrupt()
stmmac_ethtool_set_link_ksettings()
stmmac_ethtool_get_link_ksettings()
will all ignore the presence of the PCS. The latter two will pass the ethtool commands to phylink. The former will avoid manipulating the netif carrier state behind phylink's back based on the PCS status.
This flag is only set by the ethqos driver. From what I can tell, amongst the current kernel DT files that use the ethqos driver, only sa8775p-ride.dts enables ethernet, and this defines a SGMII-mode link to its PHYs without the "managed" property. Thus, phylink will be operating in MLO_AN_PHY mode, and inband mode will not be used.
Therefore, it is safe to ignore the STMMAC_FLAG_HAS_INTEGRATED_PCS flag in stmmac_mac_select_pcs().
Further code analysis shows that XPCS is used by Intel for Cisco SGMII and 1000base-X modes. In this case, we do not want to provide the integrated PCS, but the XPCS. The same appears to also be true of the Lynx PCS.
Therefore, it seems that the integrated PCS provided by the hwif MAC code should only be used when an external PCS is not being used, so give priority to the external PCS.
Provide a phylink_pcs instance in struct mac_device_info for hwifs to use to provide their phylink PCS.
Omit the non-phylink PCS code paths when a hwif provides a phylink_select_pcs() method (in other words, when they are converted to use a phylink PCS.) This provides a way to transition parts of the driver in the subsequent patches.
--- drivers/net/ethernet/stmicro/stmmac/common.h | 15 ++++++++++++++- drivers/net/ethernet/stmicro/stmmac/hwif.h | 19 +++++++++++++++++-- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 10 ++++++---- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++++--- 4 files changed, 41 insertions(+), 10 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +14 -1
@@ -14,7 +14,7 @@#include <linux/etherdevice.h> #include <linux/netdevice.h> #include <linux/stmmac.h> -#include <linux/phy.h> +#include <linux/phylink.h> #include <linux/pcs/pcs-xpcs.h> #include <linux/module.h> #if IS_ENABLED (CONFIG_VLAN_8021Q )
@@ -582,6 +582,18 @@ struct mii_regs {unsigned int clk_csr_mask; }; +struct stmmac_pcs { +struct stmmac_priv *priv; +void __iomem *pcs_base; +struct phylink_pcs pcs; +}; + +static inline struct stmmac_pcs * +phylink_pcs_to_stmmac_pcs (struct phylink_pcs *pcs) +{ + return container_of(pcs, struct stmmac_pcs, pcs); +} +struct mac_device_info {const struct stmmac_ops *mac;const struct stmmac_desc_ops *desc;
@@ -591,6 +603,7 @@ struct mac_device_info {const struct stmmac_tc_ops *tc;const struct stmmac_mmc_ops *mmc;const struct stmmac_est_ops *est; +struct stmmac_pcs mac_pcs;struct dw_xpcs *xpcs;struct phylink_pcs *phylink_pcs;struct mii_regs mii;/* MII register Addresses */
drivers/net/ethernet/stmicro/stmmac/hwif.h +17 -2
@@ -5,6 +5,7 @@#ifndef __STMMAC_HWIF_H__#define __STMMAC_HWIF_H__ +#include <linux/err.h> #include <linux/netdevice.h> #include <linux/stmmac.h>
@@ -17,13 +18,17 @@ } \ __result; \ }) -#define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \ +#define stmmac_do_typed_callback (__type, __fail_ret, __priv, __module, \ + __cname, __arg0, __args...) \ ({ \ - int __result = -EINVAL; \ + __type __result = __fail_ret; \ if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) \ __result = (__priv)->hw->__module->__cname((__arg0), ##__args); \ __result; \ }) +#define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \ + stmmac_do_typed_callback(int, -EINVAL, __priv, __module, __cname, \ + __arg0, ##__args)struct stmmac_extra_stats ;struct stmmac_priv ;
@@ -310,6 +315,9 @@ struct stmmac_ops {void (*core_init)(struct mac_device_info *hw,struct net_device *dev);/* Update MAC capabilities */ void (*update_caps)(struct stmmac_priv *priv); +/* Get phylink PCS (for MAC) */ +struct phylink_pcs *(*phylink_select_pcs)(struct stmmac_priv *priv, +phy_interface_t interface);/* Enable the MAC RX/TX */ void (*set_mac)(void __iomem *ioaddr,bool enable);/* Enable and verify that the IPC module is supported */
@@ -430,6 +438,10 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, core_init, __args)#define stmmac_mac_update_caps (__priv) \ stmmac_do_void_callback(__priv, mac, update_caps, __priv) +#define stmmac_mac_phylink_select_pcs (__priv, __interface) \ + stmmac_do_typed_callback(struct phylink_pcs *, ERR_PTR(-EOPNOTSUPP), \ + __priv, mac, phylink_select_pcs, __priv,\ + __interface) #define stmmac_mac_set(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, set_mac, __args) #define stmmac_rx_ipc(__priv, __args...) \
@@ -527,6 +539,9 @@ struct stmmac_ops { #define stmmac_fpe_irq_status(__priv, __args...) \ stmmac_do_callback(__priv, mac, fpe_irq_status, __args) +#define stmmac_has_mac_phylink_select_pcs (__priv) \ + ((__priv)->hw->mac->phylink_select_pcs != NULL) +/* PTP and HW Timer helpers */ struct stmmac_hwtimestamp {void (*config_hw_tstamping) (void __iomem *ioaddr,u32 data);
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +6 -4
@@ -323,7 +323,8 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev,if (!(priv->plat->flags &STMMAC_FLAG_HAS_INTEGRATED_PCS ) && (priv->hw->pcs &STMMAC_PCS_RGMII || - priv->hw->pcs &STMMAC_PCS_SGMII )) { + priv->hw->pcs &STMMAC_PCS_SGMII ) && + !stmmac_has_mac_phylink_select_pcs (priv)) {u32 supported, advertising, lp_advertising;if (!priv->xstats.pcs_link) {
@@ -373,7 +374,8 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev,if (!(priv->plat->flags &STMMAC_FLAG_HAS_INTEGRATED_PCS ) && (priv->hw->pcs &STMMAC_PCS_RGMII || - priv->hw->pcs &STMMAC_PCS_SGMII )) { + priv->hw->pcs &STMMAC_PCS_SGMII ) && + !stmmac_has_mac_phylink_select_pcs (priv)) {/* Only support ANE */ if (cmd->base.autoneg !=AUTONEG_ENABLE )return -EINVAL ;
@@ -485,7 +487,7 @@ stmmac_get_pauseparam(struct net_device *netdev, {struct stmmac_priv *priv =netdev_priv (netdev); -if (priv->hw->pcs) { +if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs (priv)) { pause->autoneg =1 ; }else {phylink_ethtool_get_pauseparam (priv->phylink, pause);
@@ -498,7 +500,7 @@ stmmac_set_pauseparam(struct net_device *netdev, {struct stmmac_priv *priv =netdev_priv (netdev); -if (priv->hw->pcs) { +if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs (priv)) { pause->autoneg =1 ;return 0 ; }else {
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -3
@@ -957,7 +957,7 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,return pcs; } -return NULL ; +return stmmac_mac_phylink_select_pcs (priv, interface); } static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
@@ -3486,7 +3486,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) } } -if (priv->hw->pcs) +if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs (priv))stmmac_pcs_ctrl_ane (priv,1 , priv->hw->ps,0 );/* set TX and RX rings length */
@@ -6064,7 +6064,8 @@ static void stmmac_common_interrupt(struct stmmac_priv *priv)/* PCS link status */ if (priv->hw->pcs && - !(priv->plat->flags &STMMAC_FLAG_HAS_INTEGRATED_PCS )) { + !(priv->plat->flags &STMMAC_FLAG_HAS_INTEGRATED_PCS ) && + !stmmac_has_mac_phylink_select_pcs (priv)) {if (priv->xstats.pcs_link)netif_carrier_on (priv->dev);else
Signature · 1 line
2.30.2
RFC PATCH v4 5/14 net: stmmac: provide core phylink PCS infrastructure
In reply to Russell King (Oracle)There are some common operations shared between the dwmac hwifs, the only difference is where they are located within the device. These are already present in the form of dwmac_rane() and dwmac_ctrl_ane(). Rather than use these (which don't quite fit with phylink PCS, provide phylink PCS specific versions. Also provide an implementation to parse the RSGMII status register.
--- drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 47 +++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 50 +++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -1
@@ -6,7 +6,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \ mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o \ dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \ stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \ - stmmac_xdp.o stmmac_est.o \ + stmmac_xdp.o stmmac_est.o stmmac_pcs.o \ $(stmmac-y) stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c new file +47 -0
47 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +50 -0
60 lines not on this page · raw message
Signature · 1 line
2.30.2
RFC PATCH v4 6/14 net: stmmac: dwmac1000: convert sgmii/rgmii "pcs" to phylink
In reply to Russell King (Oracle)Convert dwmac1000 sgmii/rgmii "pcs" implementation to use a phylink_pcs so we can eventually get rid of the exceptional paths that conflict with phylink.
We do not provide a validate method to enforce auto-negotiation, because the ethtool autonegotiation is a property of the media facing link, not of the internal network device links.
--- .../net/ethernet/stmicro/stmmac/dwmac1000.h | 13 +--- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 73 ++++++++++--------- 2 files changed, 39 insertions(+), 47 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +1 -12
@@ -86,19 +86,8 @@ enum power_event {#define GMAC_RGSMIIIS 0x000000d8/* RGMII/SMII status */ /* SGMII/RGMII status register */ -#define GMAC_RGSMIIIS_LNKMODE BIT(0) -#define GMAC_RGSMIIIS_SPEED GENMASK(2, 1) -#define GMAC_RGSMIIIS_SPEED_SHIFT 1 -#define GMAC_RGSMIIIS_LNKSTS BIT(3) -#define GMAC_RGSMIIIS_JABTO BIT(4) -#define GMAC_RGSMIIIS_FALSECARDET BIT(5) +#define GMAC_RGSMIIIS_RS_STAT GENMASK(15, 0)#define GMAC_RGSMIIIS_SMIDRXS BIT(16) -/* LNKMOD */ -#define GMAC_RGSMIIIS_LNKMOD_MASK 0x1 -/* LNKSPEED */ -#define GMAC_RGSMIIIS_SPEED_125 0x2 -#define GMAC_RGSMIIIS_SPEED_25 0x1 -#define GMAC_RGSMIIIS_SPEED_2_5 0x0/* GMAC Configuration defines */ #define GMAC_CONTROL_2K 0x08000000/* IEEE 802.3as 2K packets */
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +38 -35
108 lines not on this page · raw message
Signature · 1 line
2.30.2
RFC PATCH v4 7/14 net: stmmac: dwmac1000: move PCS interrupt control
In reply to Russell King (Oracle)Control the PCS interrupt mask from phylink's pcs_enable() and pcs_disable() methods rather than relying on driver variables.
This assumes that GMAC_INT_DISABLE_RGMII, GMAC_INT_DISABLE_PCSLINK and GMAC_INT_DISABLE_PCSAN are all relevant to the PCS.
--- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +27 -6
@@ -56,12 +56,7 @@ static void dwmac1000_core_init(struct mac_device_info *hw,writel (value, ioaddr +GMAC_CONTROL );/* Mask GMAC interrupts */ - value =GMAC_INT_DEFAULT_MASK ; - -if (hw->pcs) - value &= ~GMAC_INT_DISABLE_PCS ; - -writel (value, ioaddr +GMAC_INT_MASK ); +writel (GMAC_INT_DEFAULT_MASK , ioaddr +GMAC_INT_MASK );#ifdef STMMAC_VLAN_TAG_USED /* Tag detection without filtering */
@@ -376,6 +371,30 @@ static void dwmac1000_ctrl_ane(struct stmmac_priv *priv, bool ane,dwmac_ctrl_ane (priv->ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); } +static int dwmac1000_mii_pcs_enable (struct phylink_pcs *pcs) +{ +struct stmmac_pcs *spcs =phylink_pcs_to_stmmac_pcs (pcs); +void __iomem *ioaddr = spcs->priv->hw->pcsr; +u32 intr_mask; + + intr_mask =readl (ioaddr +GMAC_INT_MASK ); + intr_mask &= ~GMAC_INT_DISABLE_PCS ; +writel (intr_mask, ioaddr +GMAC_INT_MASK ); + +return 0 ; +} + +static void dwmac1000_mii_pcs_disable (struct phylink_pcs *pcs) +{ +struct stmmac_pcs *spcs =phylink_pcs_to_stmmac_pcs (pcs); +void __iomem *ioaddr = spcs->priv->hw->pcsr; +u32 intr_mask; + + intr_mask =readl (ioaddr +GMAC_INT_MASK ); + intr_mask |=GMAC_INT_DISABLE_PCS ; +writel (intr_mask, ioaddr +GMAC_INT_MASK ); +} +static void dwmac1000_mii_pcs_get_state (struct phylink_pcs *pcs,struct phylink_link_state *state) {
@@ -386,6 +405,8 @@ static void dwmac1000_mii_pcs_get_state(struct phylink_pcs *pcs, }static const struct phylink_pcs_ops dwmac1000_mii_pcs_ops = { + .pcs_enable = dwmac1000_mii_pcs_enable, + .pcs_disable = dwmac1000_mii_pcs_disable, .pcs_config = dwmac_pcs_config, .pcs_get_state = dwmac1000_mii_pcs_get_state, };
Signature · 1 line
2.30.2
RFC PATCH v4 8/14 net: stmmac: dwmac4: convert sgmii/rgmii "pcs" to phylink
In reply to Russell King (Oracle)Convert dwmac4 sgmii/rgmii "pcs" implementation to use a phylink_pcs so we can eventually get rid of the exceptional paths that conflict with phylink.
We do not provide a validate method to enforce auto-negotiation, because the ethtool autonegotiation is a property of the media facing link, not of the internal network device links.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 13 +---- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 58 +++++++++++-------- 2 files changed, 34 insertions(+), 37 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4.h +1 -12
@@ -567,18 +567,7 @@ static inline u32 mtl_low_credx_base_addr(const struct dwmac4_addrs *addrs,#define GMAC_PHYIF_CTRLSTATUS_TC BIT(0)#define GMAC_PHYIF_CTRLSTATUS_LUD BIT(1)#define GMAC_PHYIF_CTRLSTATUS_SMIDRXS BIT(4) -#define GMAC_PHYIF_CTRLSTATUS_LNKMOD BIT(16) -#define GMAC_PHYIF_CTRLSTATUS_SPEED GENMASK(18, 17) -#define GMAC_PHYIF_CTRLSTATUS_SPEED_SHIFT 17 -#define GMAC_PHYIF_CTRLSTATUS_LNKSTS BIT(19) -#define GMAC_PHYIF_CTRLSTATUS_JABTO BIT(20) -#define GMAC_PHYIF_CTRLSTATUS_FALSECARDET BIT(21) -/* LNKMOD */ -#define GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK 0x1 -/* LNKSPEED */ -#define GMAC_PHYIF_CTRLSTATUS_SPEED_125 0x2 -#define GMAC_PHYIF_CTRLSTATUS_SPEED_25 0x1 -#define GMAC_PHYIF_CTRLSTATUS_SPEED_2_5 0x0 +#define GMAC_PHYIF_CTRLSTATUS_RS_STAT GENMASK(31, 16)extern const struct stmmac_dma_ops dwmac4_dma_ops;extern const struct stmmac_dma_ops dwmac410_dma_ops;
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +33 -25
107 lines not on this page · raw message
Signature · 1 line
2.30.2
RFC PATCH v4 9/14 net: stmmac: dwmac4: move PCS interrupt control
In reply to Russell King (Oracle)Control the PCS interrupt mask from the phylink pcs_enable() and pcs_disable() methods rather than relying on driver variables.
This assumes that GMAC_INT_RGSMIIS, GMAC_INT_PCS_LINK and GMAC_INT_PCS_ANE are all relevant to the PCS.
--- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +26 -4
@@ -56,9 +56,6 @@ static void dwmac4_core_init(struct mac_device_info *hw,/* Enable GMAC interrupts */ value =GMAC_INT_DEFAULT_ENABLE ; -if (hw->pcs) - value |=GMAC_PCS_IRQ_DEFAULT ; -/* Enable FPE interrupt */ if ((GMAC_HW_FEAT_FPESEL &readl (ioaddr +GMAC_HW_FEATURE3 )) >>26 ) value |=GMAC_INT_FPE_EN ;
@@ -759,6 +756,30 @@ static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral,dwmac_ctrl_ane (priv->ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); } +static int dwmac4_mii_pcs_enable (struct phylink_pcs *pcs) +{ +struct stmmac_pcs *spcs =phylink_pcs_to_stmmac_pcs (pcs); +void __iomem *ioaddr = spcs->priv->hw->pcsr; +u32 intr_enable; + + intr_enable =readl (ioaddr +GMAC_INT_EN ); + intr_enable |=GMAC_PCS_IRQ_DEFAULT ; +writel (intr_enable, ioaddr +GMAC_INT_EN ); + +return 0 ; +} + +static void dwmac4_mii_pcs_disable (struct phylink_pcs *pcs) +{ +struct stmmac_pcs *spcs =phylink_pcs_to_stmmac_pcs (pcs); +void __iomem *ioaddr = spcs->priv->hw->pcsr; +u32 intr_enable; + + intr_enable =readl (ioaddr +GMAC_INT_EN ); + intr_enable &= ~GMAC_PCS_IRQ_DEFAULT ; +writel (intr_enable, ioaddr +GMAC_INT_EN ); +} +static void dwmac4_mii_pcs_get_state (struct phylink_pcs *pcs,struct phylink_link_state *state) {
@@ -772,11 +793,12 @@ static void dwmac4_mii_pcs_get_state(struct phylink_pcs *pcs, }static const struct phylink_pcs_ops dwmac4_mii_pcs_ops = { + .pcs_enable = dwmac4_mii_pcs_enable, + .pcs_disable = dwmac4_mii_pcs_disable, .pcs_config = dwmac_pcs_config, .pcs_get_state = dwmac4_mii_pcs_get_state, }; -static struct phylink_pcs *dwmac4_phylink_select_pcs (struct stmmac_priv *priv,phy_interface_t interface) {
Signature · 1 line
2.30.2
RFC PATCH v4 10/14 net: stmmac: move dwmac_ctrl_ane() into stmmac_pcs.c
In reply to Russell King (Oracle)Move dwmac_ctrl_ane() into stmmac_pcs.c, changing its arguments to take the stmmac_priv structure. Update it to use the previously provided __dwmac_ctrl_ane() function, which makes use of the stmmac_pcs struct and thus does not require passing the PCS base address offset.
This removes the core-specific functions, instead pointing the method at the generic method in stmmac_pcs.c.
--- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 8 +--- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 12 ++---- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 16 ++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 37 ++----------------- 4 files changed, 23 insertions(+), 50 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +1 -7
@@ -365,12 +365,6 @@ static void dwmac1000_set_eee_timer(struct mac_device_info *hw, int ls, int tw)writel (value, ioaddr +LPI_TIMER_CTRL ); } -static void dwmac1000_ctrl_ane (struct stmmac_priv *priv,bool ane, -bool srgmi_ral,bool loopback) -{ -dwmac_ctrl_ane (priv->ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); -} -static int dwmac1000_mii_pcs_enable (struct phylink_pcs *pcs) {struct stmmac_pcs *spcs =phylink_pcs_to_stmmac_pcs (pcs);
@@ -527,7 +521,7 @@ const struct stmmac_ops dwmac1000_ops = { .set_eee_timer = dwmac1000_set_eee_timer, .set_eee_pls = dwmac1000_set_eee_pls, .debug = dwmac1000_debug, - .pcs_ctrl_ane = dwmac1000_ctrl_ane, + .pcs_ctrl_ane = dwmac_ctrl_ane, .set_mac_loopback = dwmac1000_set_mac_loopback, };
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +3 -9
@@ -750,12 +750,6 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, } } -static void dwmac4_ctrl_ane (struct stmmac_priv *priv,bool ane,bool srgmi_ral, -bool loopback) -{ -dwmac_ctrl_ane (priv->ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); -} -static int dwmac4_mii_pcs_enable (struct phylink_pcs *pcs) {struct stmmac_pcs *spcs =phylink_pcs_to_stmmac_pcs (pcs);
@@ -1227,7 +1221,7 @@ const struct stmmac_ops dwmac4_ops = { .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, - .pcs_ctrl_ane = dwmac4_ctrl_ane, + .pcs_ctrl_ane = dwmac_ctrl_ane, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .set_mac_loopback = dwmac4_set_mac_loopback,
@@ -1271,7 +1265,7 @@ const struct stmmac_ops dwmac410_ops = { .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, - .pcs_ctrl_ane = dwmac4_ctrl_ane, + .pcs_ctrl_ane = dwmac_ctrl_ane, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .flex_pps_config = dwmac5_flex_pps_config,
@@ -1319,7 +1313,7 @@ const struct stmmac_ops dwmac510_ops = { .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer, .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, - .pcs_ctrl_ane = dwmac4_ctrl_ane, + .pcs_ctrl_ane = dwmac_ctrl_ane, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, .safety_feat_config = dwmac5_safety_feat_config,
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c +16 -0
@@ -30,6 +30,22 @@ static void __dwmac_ctrl_ane(struct stmmac_pcs *spcs, bool ane, bool srgmi_ral,writel (val, spcs->pcs_base +GMAC_AN_CTRL (0 )); } +/** +* dwmac_ctrl_ane - To program the AN Control Register. +* @priv: pointer to &struct stmmac_priv +* @ane: to enable the auto-negotiation +* @srgmi_ral: to manage MAC-2-MAC SGMII connections. +* @loopback: to cause the PHY to loopback tx data into rx path. +* Description: this is the main function to configure the AN control register +* and init the ANE, select loopback (usually for debugging purpose) and +* configure SGMII RAL. +*/ +void dwmac_ctrl_ane (struct stmmac_priv *priv,bool ane,bool srgmi_ral, +bool loopback) +{ +__dwmac_ctrl_ane (&priv->hw->mac_pcs, ane, srgmi_ral, loopback); +} + int dwmac_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, const unsigned long *advertising,
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +3 -34
@@ -89,40 +89,6 @@ static inline void dwmac_pcs_isr(void __iomem *ioaddr, u32 reg, } } -/** -* dwmac_ctrl_ane - To program the AN Control Register. -* @ioaddr: IO registers pointer -* @reg: Base address of the AN Control Register. -* @ane: to enable the auto-negotiation -* @srgmi_ral: to manage MAC-2-MAC SGMII connections. -* @loopback: to cause the PHY to loopback tx data into rx path. -* Description: this is the main function to configure the AN control register -* and init the ANE, select loopback (usually for debugging purpose) and -* configure SGMII RAL. -*/ -static inline void dwmac_ctrl_ane (void __iomem *ioaddr,u32 reg,bool ane, -bool srgmi_ral,bool loopback) -{ -u32 value =readl (ioaddr +GMAC_AN_CTRL (reg)); - -/* Enable and restart the Auto-Negotiation */ -if (ane) - value |=GMAC_AN_CTRL_ANE |GMAC_AN_CTRL_RAN ; -else - value &= ~GMAC_AN_CTRL_ANE ; - -/* In case of MAC-2-MAC connection, block is configured to operate -* according to MAC conf register. -*/ -if (srgmi_ral) - value |=GMAC_AN_CTRL_SGMRAL ; - -if (loopback) - value |=GMAC_AN_CTRL_ELE ; - -writel (value, ioaddr +GMAC_AN_CTRL (reg)); -} -static inline bool dwmac_rs_decode_stat (struct phylink_link_state *state,uint16_t rs_stat) {
@@ -154,6 +120,9 @@ static inline bool dwmac_rs_decode_stat(struct phylink_link_state *state,return true; } +void dwmac_ctrl_ane (struct stmmac_priv *priv,bool ane,bool srgmi_ral, +bool loopback); + int dwmac_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, const unsigned long *advertising,
Signature · 1 line
2.30.2
RFC PATCH v4 11/14 net: stmmac: pass stmmac_pcs into dwmac_pcs_isr()
In reply to Russell King (Oracle)As the stmmac_pcs has the base address of the PCS registers, pass this into dwmac_pcs_isr() to avoid recalculating the base address.
--- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 3 ++- drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +1 -1
@@ -296,7 +296,7 @@ static int dwmac1000_irq_status(struct mac_device_info *hw, x->irq_rx_path_exit_lpi_mode_n++; } -dwmac_pcs_isr (ioaddr,GMAC_PCS_BASE , intr_status, x); +dwmac_pcs_isr (&hw->mac_pcs, intr_status, x);if (intr_status &PCS_RGSMIIIS_IRQ ) {/* TODO Dummy-read to clear the IRQ status */
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +2 -1
@@ -873,7 +873,8 @@ static int dwmac4_irq_status(struct mac_device_info *hw, x->irq_rx_path_exit_lpi_mode_n++; } -dwmac_pcs_isr (ioaddr,GMAC_PCS_BASE , intr_status, x); +dwmac_pcs_isr (&hw->mac_pcs, intr_status, x); +if (intr_status &PCS_RGSMIIIS_IRQ ) {/* TODO Dummy-read to clear the IRQ status */ readl (ioaddr +GMAC_PHYIF_CONTROL_STATUS );
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +3 -4
@@ -61,18 +61,17 @@/** * dwmac_pcs_isr - TBI, RTBI, or SGMII PHY ISR -* @ioaddr: IO registers pointer -* @reg: Base address of the AN Control Register. +* @spcs: pointer to &struct stmmac_pcs * @intr_status: GMAC core interrupt status * @x: pointer to log these events as stats * Description: it is the ISR for PCS events: Auto-Negotiation Completed and * Link status. */ -static inline void dwmac_pcs_isr (void __iomem *ioaddr,u32 reg, +static inline void dwmac_pcs_isr (struct stmmac_pcs *spcs,unsigned int intr_status,struct stmmac_extra_stats *x) { -u32 val =readl (ioaddr +GMAC_AN_STATUS (reg)); +u32 val =readl (spcs->pcs_base +GMAC_AN_STATUS (0 ));if (intr_status &PCS_ANE_IRQ ) { x->irq_pcs_ane_n++;
Signature · 1 line
2.30.2
RFC PATCH v4 12/14 net: stmmac: rename PCS registers
In reply to Russell King (Oracle)Rename the PCS registers from GMAC_xxx to STMMAC_PCS_xxx to make it clear that they are for the PCS. Avoid using PCS_ as this is too generic and may (eventually) clash with definitions elsewhere in the kernel.
--- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 16 +++--- .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 52 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c +8 -8
@@ -8,26 +8,26 @@ static void __dwmac_ctrl_ane(struct stmmac_pcs *spcs, bool ane, bool srgmi_ral, {u32 val; - val =readl (spcs->pcs_base +GMAC_AN_CTRL (0 )); + val =readl (spcs->pcs_base +STMMAC_PCS_AN_CTRL );/* Enable and restart the Auto-Negotiation */ if (ane) - val |=GMAC_AN_CTRL_ANE |GMAC_AN_CTRL_RAN ; + val |=STMMAC_PCS_AN_CTRL_ANE |STMMAC_PCS_AN_CTRL_RAN ;else - val &= ~GMAC_AN_CTRL_ANE ; + val &= ~STMMAC_PCS_AN_CTRL_ANE ;/* In case of MAC-2-MAC connection, block is configured to operate * according to MAC conf register. */ if (srgmi_ral) - val |=GMAC_AN_CTRL_SGMRAL ; + val |=STMMAC_PCS_AN_CTRL_SGMRAL ;if (loopback) - val |=GMAC_AN_CTRL_ELE ; + val |=STMMAC_PCS_AN_CTRL_ELE ;else - val &= ~GMAC_AN_CTRL_ELE ; + val &= ~STMMAC_PCS_AN_CTRL_ELE ; -writel (val, spcs->pcs_base +GMAC_AN_CTRL (0 )); +writel (val, spcs->pcs_base +STMMAC_PCS_AN_CTRL ); }/**
@@ -53,7 +53,7 @@ int dwmac_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, {struct stmmac_pcs *spcs =phylink_pcs_to_stmmac_pcs (pcs); -/* The RGMII interface does not have the GMAC_AN_CTRL register */ +/* The RGMII interface does not have the STMMAC_PCS_AN_CTRL register */ if (phy_interface_mode_is_rgmii (spcs->priv->plat->mac_interface))return 0 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +26 -26
80 lines not on this page · raw message
Signature · 1 line
2.30.2
RFC PATCH v4 13/14 net: stmmac: remove obsolete pcs methods and associated code
In reply to Russell King (Oracle)The pcs_ctrl_ane() method is no longer required as this will be handled by the mac_pcs phylink_pcs instance. Remove these methods, their common implementation, the pcs_link, pcs_duplex and pcs_speed members of struct stmmac_extra_stats, and stmmac_has_mac_phylink_select_pcs().
--- drivers/net/ethernet/stmicro/stmmac/common.h | 10 --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 -- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 70 +------------------ .../net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ---- 4 files changed, 2 insertions(+), 95 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +0 -10
@@ -191,9 +191,6 @@ struct stmmac_extra_stats {unsigned long irq_pcs_ane_n;unsigned long irq_pcs_link_n;unsigned long irq_rgmii_n; -unsigned long pcs_link; -unsigned long pcs_duplex; -unsigned long pcs_speed;/* debug register */ unsigned long mtl_tx_status_fifo_full;unsigned long mtl_tx_fifo_not_empty;
@@ -394,13 +391,6 @@ enum request_irq_err {#define CORE_IRQ_MTL_RX_OVERFLOW BIT(8)/* Physical Coding Sublayer */ -struct rgmii_adv { -unsigned int pause; -unsigned int duplex; -unsigned int lp_pause; -unsigned int lp_duplex; -}; -#define STMMAC_PCS_PAUSE 1#define STMMAC_PCS_ASYM_PAUSE 2
drivers/net/ethernet/stmicro/stmmac/hwif.h +0 -4
@@ -303,7 +303,6 @@ struct stmmac_dma_ops {struct mac_device_info ;struct net_device ; -struct rgmii_adv ;struct stmmac_tc_entry ;struct stmmac_pps_cfg ;struct stmmac_rss ;
@@ -539,9 +538,6 @@ struct stmmac_ops { #define stmmac_fpe_irq_status(__priv, __args...) \ stmmac_do_callback(__priv, mac, fpe_irq_status, __args) -#define stmmac_has_mac_phylink_select_pcs (__priv) \ - ((__priv)->hw->mac->phylink_select_pcs != NULL) -/* PTP and HW Timer helpers */ struct stmmac_hwtimestamp {void (*config_hw_tstamping) (void __iomem *ioaddr,u32 data);
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +2 -68
94 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -13
@@ -3486,9 +3486,6 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) } } -if (priv->hw->pcs && !stmmac_has_mac_phylink_select_pcs (priv)) -stmmac_pcs_ctrl_ane (priv,1 , priv->hw->ps,0 ); -/* set TX and RX rings length */ stmmac_set_rings_length (priv);
@@ -6062,16 +6059,6 @@ static void stmmac_common_interrupt(struct stmmac_priv *priv)for (queue =0 ; queue < queues_count; queue++)stmmac_host_mtl_irq_status (priv, priv->hw, queue); -/* PCS link status */ -if (priv->hw->pcs && - !(priv->plat->flags &STMMAC_FLAG_HAS_INTEGRATED_PCS ) && - !stmmac_has_mac_phylink_select_pcs (priv)) { -if (priv->xstats.pcs_link) -netif_carrier_on (priv->dev); -else -netif_carrier_off (priv->dev); - } -stmmac_timestamp_interrupt (priv, priv); } }
Signature · 1 line
2.30.2
RFC PATCH v4 14/14 net: stmmac: Activate Inband/PCS flag based on the selected iface
In reply to Russell King (Oracle)From: Serge Semin <[email protected]>
The HWFEATURE.PCSSEL flag is set if the PCS block has been synthesized into the DW GMAC controller. It's always done if the controller supports at least one of the SGMII, TBI, RTBI PHY interfaces. If none of these interfaces support was activated during the IP-core synthesize the PCS block won't be activated either and the HWFEATURE.PCSSEL flag won't be set. Based on that the RGMII in-band status detection procedure implemented in the driver hasn't been working for the devices with the RGMII interface support and with none of the SGMII, TBI, RTBI PHY interfaces available in the device.
Fix that just by dropping the dma_cap.pcs flag check from the conditional statement responsible for the In-band/PCS functionality activation. If the RGMII interface is supported by the device then the in-band link status detection will be also supported automatically (it's always embedded into the RGMII RTL code). If the SGMII interface is supported by the device then the PCS block will be supported too (it's unconditionally synthesized into the controller). The later is also correct for the TBI/RTBI PHY interfaces.
Note while at it drop the netdev_dbg() calls since at the moment of the stmmac_check_pcs_mode() invocation the network device isn't registered. So the debug prints will be for the unknown/NULL device.
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -12
@@ -1133,18 +1133,10 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv) {int interface = priv->plat->mac_interface; -if (priv->dma_cap.pcs) { -if ((interface ==PHY_INTERFACE_MODE_RGMII ) || - (interface ==PHY_INTERFACE_MODE_RGMII_ID ) || - (interface ==PHY_INTERFACE_MODE_RGMII_RXID ) || - (interface ==PHY_INTERFACE_MODE_RGMII_TXID )) { -netdev_dbg (priv->dev,"PCS RGMII support enabled\n" ); - priv->hw->pcs =STMMAC_PCS_RGMII ; - }else if (interface ==PHY_INTERFACE_MODE_SGMII ) { -netdev_dbg (priv->dev,"PCS SGMII support enabled\n" ); - priv->hw->pcs =STMMAC_PCS_SGMII ; - } - } +if (phy_interface_mode_is_rgmii (interface)) + priv->hw->pcs =STMMAC_PCS_RGMII ; +else if (priv->dma_cap.pcs && interface ==PHY_INTERFACE_MODE_SGMII ) + priv->hw->pcs =STMMAC_PCS_SGMII ; }/**
Signature · 1 line
2.30.2
Hi Russell
Quoted 9 lines · Russell King (Oracle)
Hi,
Changes since version 3:
- added Andrew's reviewed-bys
- fixed kernel-doc fordwmac_pcs_isr()
- updated patch 11 commit message
- fixed build error reported by Jakub
- add Sneh Shah to Cc list (for testing 2.5G modes)
Quoted 3 lines
Bartosz - I know you've given your tested-by this morning, I will be adding that after posting this series, so please don't think it's been lost!
Got this series tested on my DW GMAC v3.73a + Micrel KSZ9031RNX PHY with the in-band link status management enabled. The same positive result as before, on v1-v2:
[ 294.651324] stmmaceth 1f060000.ethernet eth1: configuring for inband/rgmii-rxid link mode [ 294.582498] stmmaceth 1f060000.ethernet eth1: Register MEM_TYPE_PAGE_POOL RxQ-0 [ 294.594308] stmmaceth 1f060000.ethernet eth1: PHY [stmmac-1:03] driver [RTL8211E Gigabit Ethernet] (irq=POLL) [ 294.605453] dwmac1000: Master AXI performs any burst length [ 294.611899] stmmaceth 1f060000.ethernet: invalid port speed [ 294.618229] stmmaceth 1f060000.ethernet eth1: No Safety Features support found [ 294.626412] stmmaceth 1f060000.ethernet eth1: No MAC Management Counters available [ 294.634912] stmmaceth 1f060000.ethernet eth1: IEEE 1588-2008 Advanced Timestamp supported [ 294.644380] stmmaceth 1f060000.ethernet eth1: registered PTP clock [ 294.651324] stmmaceth 1f060000.ethernet eth1: configuring for inband/rgmii-rxid link mode ... [ 298.772917] stmmaceth 1f060000.ethernet eth1: Link is Up - 1Gbps/Full - flow control rx/tx
So feel free to add:
Please note the warning: "stmmaceth 1f060000.ethernet: invalid port speed" in the log above. This is a false negative warning since my network devices isn't of MAC2MAC-type and there is no snps,ps-speed property in my dts. So having the priv->hw.ps set to zero should be fine. That said I guess we need to add the warning fix to the 14/14 patch which would permit the plat_stmmacenet_data::mac_port_sel_speed field being zero.
Quoted 32 lines
Previous cover messages from earlier posts below:
This is version 3 of the series switching stmmac to use phylink PCS isntead of going behind phylink's back.
Changes since version 2:
- Adopted some of Serge's feedback.
- New patch: addingethqos_pcs_set_inband()for qcom-ethqos so we have one place to modify for AN control rather than many.
- New patch: pass thestmmac_privstructure into thepcs_set_ane()method.
- New patch: removepcs_get_adv_lp()early, as this is only for TBI and RTBI, support for which we dropped in an already merged patch.
- Providestmmac_pcsstructure to encapsulate the pointer tostmmac_priv, PCS MMIO address pointer andphylink_pcsstructure.
- Restructuredwmac_pcs_config()so we can eventually share code withdwmac_ctrl_ane().
- New patch: movedwmac_ctrl_ane()intostmmac_pcs.c, and share code.
- New patch: pass thestmmac_pcsstructure intodwmac_pcs_isr().
- New patch: similar to Serge's patch, rename the PCS registers, but useSTMMAC_PCS_as the prefix rather than justPCS_which is too generic.
- New patch: incorporate "net: stmmac: Activate Inband/PCS flag based on the selected iface" from Serge.On the subject of whether we should have two PCS instances, I experimented with that and have now decided against it. Instead,
dwmac_pcs_config()now tests whether we need to fiddle with the PCS control register or not.
Quoted 4 lines
Note that I prefer not to have multiple layers of indirection, but instead prefer a library-style approach, which is why I haven't turned the PCS support into something that's self contained with a method in the MAC driver to grab the RGSMII status.
I understand the reason of your choice in this case. As a result a some part of my changes haven't been merged in into your series. But I deliberately selected the approach with having the simple PCS HW-interface callbacks utilized for a self-contained internal PCS implementation. Here is why:
1. Signify that the DW GMAC and DW QoS Eth internal PCSs are the same.
2. Reduce the amount of code.
3. Collects the entire PCS implementation in a single place which improves the code readability.
4. The PCS ops initialization is implemented in the same way as the PTP, MMC and EST (and likely FPE in some time in future), in the hwif.c and the interface/core callbacks in the dedicated files (stmmac_ptp.c, mmc_core.c, stmmac_est.c, etc). So the PCS implementation would be in general unified with what has been done for PTP/MMC/EST/etc.
5. ...
Taking that into account I am still convinced that my approach worth to be implemented. Hope you won't mind, if after your series is merged in I'll submit another patch set which would introduce some of my PCS-changes not included into your patch set. Like this:
1. Move the mac_device_info instance to being defined in the stmmac_priv structure (new patch, so to drop the stmmac_priv pointer from stmmac_pcs).
2. Introduce stmmac_priv::pcsaddr (to have the PCS CSR base address defined in the same way as for PTP/MMC/EST/etc).
3. Provide the HWIF ops:
stmmac_pcs_ops {
pcs_get_config_reg;
pcs_enable_irq;
pcs_disable_irq; } for DW GMAC and DW QoS Eth.
4. Move PCS implementation to stmmac_pcs.c
5. Direct using the plat_stmmacenet_data::mac_port_sel_speed field instead of the mac_device_info::ps.
6. Some more cleanups like converting the struct stmmac_hwif_entry field from void-pointers to the typed-pointers, ...
-Serge(y)
Quoted 101 lines
-----
This is version 2 of the series switching stmmac to use phylink PCS instead of going behind phylink's back.
Changes since version 1:
- Addition of patches from Serge Semin to allow RGMII to use the "PCS" code even ifpriv->dma_cap.pcsis not set (including tweaks by me.)
- Restructuring of the patch set to be a more logical split.
- Leave thepcs_ctrl_anemethods until we've worked out what to do with the qcom-ethqos driver (this series may still end up breaking it, but at least we will now successfully compile.)A reminder that what I want to hear from this patch set are the results of testing - and thanks to Serge, the RGMII paths were exercised, but I have not had any results for the SGMII side of this.
There are still a bunch of outstanding questions:
- whether we should be using two separate PCS instances, one for RGMII and another for SGMII. If the PCS hardware is not present, but are using RGMII mode, then we probably don't want to be accessing the registers that would've been there for SGMII.
- what the three interrupts associated with the PCS code actually mean when they fire.
- which block's status we're reading in thepcs_get_state()method, and whether we should be reading that for both RGMII and SGMII.
- whether we need to activate phylink's inband mode in more cases (so that the PCS/MAC status gets read and used for the link.)There's probably more questions to be asked... but really the critical thing is to shake out any breakage from making this conversion. Bear in mind that I have little knowledge of this hardware, so this conversion has been done somewhat blind using only what I can observe from the current driver.
------
As I noted recently in a thread (and was ignored) stmmac sucks. (I won't hide my distain for drivers that make my life as phylink maintainer more difficult!)
One of the contract conditions for using phylink is that the driver will _not_ mess with the netif carrier. stmmac developers/maintainers clearly didn't read that, because stmmac messes with the netif carrier, which destroys phylink's guarantee that it'll make certain calls in a particular order (e.g. it won't call
mac_link_up()twice in a row without an interveningmac_link_down().) This is clearly stated in the phylink documentation.Thus, this patch set attempts to fix this. Why does it mess with the netif carrier? It has its own independent PCS implementation that completely bypasses phylink _while_ phylink is still being used. This is not acceptable. Either the driver uses phylink, or it doesn't use phylink. There is no half-way house about this. Therefore, this driver needs to either be fixed, or needs to stop using phylink.
Since I was ignored when I brought this up, I've hacked together the following patch set - and it is hacky at the moment. It's also broken because of recentl changes involving
dwmac-qcom-ethqos.c- but there isn't sufficient information in the driver for me to fix this. The driver appears to use SGMII at 2500Mbps, which simply does not exist. What interface mode (andneg_mode) does phylink pass topcs_config()in each of the speeds thatdwmac-qcom-ethqos.cis interested in. Without this information, I can't do that conversion. So for the purposes of this, I've just ignoreddwmac-qcom-ethqos.c(which means it will fail to build.)The patch splitup is not ideal, but that's not what I'm interested in here. What I want to hear is the results of testing - does this switch of the RGMII/SGMII "pcs" stuff to a
phylink_pcswork for this driver?Please don't review the patches, but you are welcome to send fixes to them. Once we know that the overall implementation works, then I'll look at how best to split the patches. In the mean time, the present form is more convenient for making changes and fixing things.
There is still more improvement that's needed here.
Thanks.
drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +- drivers/net/ethernet/stmicro/stmmac/common.h | 25 ++-- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 13 +- drivers/net/ethernet/stmicro/stmmac/dwmac1000.h | 13 +- .../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 110 +++++++------- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 13 +- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 99 +++++++------ drivers/net/ethernet/stmicro/stmmac/hwif.h | 24 ++-- .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 111 +------------- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 30 +--- drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c | 63 ++++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h | 160 ++++++++++----------- 12 files changed, 306 insertions(+), 357 deletions(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.cSignature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Quoted 18 lines · Serge Semin
Hi Russell
Got this series tested on my DW GMAC v3.73a + Micrel KSZ9031RNX PHY with the in-band link status management enabled. The same positive result as before, on v1-v2:
[ 294.651324] stmmaceth 1f060000.ethernet eth1: configuring for inband/rgmii-rxid link mode [ 294.582498] stmmaceth 1f060000.ethernet eth1: Register MEM_TYPE_PAGE_POOL RxQ-0 [ 294.594308] stmmaceth 1f060000.ethernet eth1: PHY [stmmac-1:03] driver [RTL8211E Gigabit Ethernet] (irq=POLL) [ 294.605453] dwmac1000: Master AXI performs any burst length [ 294.611899] stmmaceth 1f060000.ethernet: invalid port speed [ 294.618229] stmmaceth 1f060000.ethernet eth1: No Safety Features support found [ 294.626412] stmmaceth 1f060000.ethernet eth1: No MAC Management Counters available [ 294.634912] stmmaceth 1f060000.ethernet eth1: IEEE 1588-2008 Advanced Timestamp supported [ 294.644380] stmmaceth 1f060000.ethernet eth1: registered PTP clock [ 294.651324] stmmaceth 1f060000.ethernet eth1: configuring for inband/rgmii-rxid link mode ... [ 298.772917] stmmaceth 1f060000.ethernet eth1: Link is Up - 1Gbps/Full - flow control rx/tx
Quoted 2 lines
So feel free to add:
Tested-by Serge Semin <[email protected]>
Thanks.
Quoted 7 lines
Please note the warning: "stmmaceth 1f060000.ethernet: invalid port speed" in the log above. This is a false negative warning since my network devices isn't of MAC2MAC-type and there is no snps,ps-speed property in my dts. So having the
priv->hw.psset to zero should be fine. That said I guess we need to add the warning fix to the 14/14 patch which would permit theplat_stmmacenet_data::mac_port_sel_speedfield being zero.
I think this is a separate issue - one which exists even today with the stmmac driver as this code hasn't changed. Maybe it should be a separate patch targetting the net tree?
Quoted 69 lines
Quoted 31 lines
Previous cover messages from earlier posts below:
This is version 3 of the series switching stmmac to use phylink PCS isntead of going behind phylink's back.
Changes since version 2:
- Adopted some of Serge's feedback.
- New patch: addingethqos_pcs_set_inband()for qcom-ethqos so we have one place to modify for AN control rather than many.
- New patch: pass thestmmac_privstructure into thepcs_set_ane()method.
- New patch: removepcs_get_adv_lp()early, as this is only for TBI and RTBI, support for which we dropped in an already merged patch.
- Providestmmac_pcsstructure to encapsulate the pointer tostmmac_priv, PCS MMIO address pointer andphylink_pcsstructure.
- Restructuredwmac_pcs_config()so we can eventually share code withdwmac_ctrl_ane().
- New patch: movedwmac_ctrl_ane()intostmmac_pcs.c, and share code.
- New patch: pass thestmmac_pcsstructure intodwmac_pcs_isr().
- New patch: similar to Serge's patch, rename the PCS registers, but useSTMMAC_PCS_as the prefix rather than justPCS_which is too generic.
- New patch: incorporate "net: stmmac: Activate Inband/PCS flag based on the selected iface" from Serge.On the subject of whether we should have two PCS instances, I experimented with that and have now decided against it. Instead,
dwmac_pcs_config()now tests whether we need to fiddle with the PCS control register or not.Quoted 4 lines
Note that I prefer not to have multiple layers of indirection, but instead prefer a library-style approach, which is why I haven't turned the PCS support into something that's self contained with a method in the MAC driver to grab the RGSMII status.
I understand the reason of your choice in this case. As a result a some part of my changes haven't been merged in into your series. But I deliberately selected the approach with having the simple PCS HW-interface callbacks utilized for a self-contained internal PCS implementation. Here is why:
1. Signify that the DW GMAC and DW QoS Eth internal PCSs are the same.
2. Reduce the amount of code.
3. Collects the entire PCS implementation in a single place which improves the code readability.
4. The PCS ops initialization is implemented in the same way as the PTP, MMC and EST (and likely FPE in some time in future), in thehwif.cand the interface/core callbacks in the dedicated files (stmmac_ptp.c,mmc_core.c,stmmac_est.c, etc). So the PCS implementation would be in general unified with what has been done for PTP/MMC/EST/etc.
5. ...Taking that into account I am still convinced that my approach worth to be implemented. Hope you won't mind, if after your series is merged in I'll submit another patch set which would introduce some of my PCS-changes not included into your patch set. Like this:
1. Move themac_device_infoinstance to being defined in thestmmac_privstructure (new patch, so to drop thestmmac_privpointer fromstmmac_pcs).
2. Introducestmmac_priv::pcsaddr(to have the PCS CSR base address defined in the same way as for PTP/MMC/EST/etc).
3. Provide the HWIF ops:stmmac_pcs_ops { pcs_get_config_reg; pcs_enable_irq; pcs_disable_irq; } for DW GMAC and DW QoS Eth.
Quoted 5 lines
4. Move PCS implementation to
stmmac_pcs.c
5. Direct using theplat_stmmacenet_data::mac_port_sel_speedfield instead of themac_device_info::ps.
6. Some more cleanups like converting the structstmmac_hwif_entryfield from void-pointers to the typed-pointers, ...
I guessed that you would dig your heals in over this, and want to do it your own way despite all the points I raised against your patch series on my previous posting arguing against much of this.
So, at this point I give up with this patch series - clearly there is no room for discussion about the way forward, and you want to do it your way no matter what.
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!
Quoted 33 lines · Russell King (Oracle)
Quoted 18 lines · Serge Semin
Hi Russell
Got this series tested on my DW GMAC v3.73a + Micrel KSZ9031RNX PHY with the in-band link status management enabled. The same positive result as before, on v1-v2:
[ 294.651324] stmmaceth 1f060000.ethernet eth1: configuring for inband/rgmii-rxid link mode [ 294.582498] stmmaceth 1f060000.ethernet eth1: Register MEM_TYPE_PAGE_POOL RxQ-0 [ 294.594308] stmmaceth 1f060000.ethernet eth1: PHY [stmmac-1:03] driver [RTL8211E Gigabit Ethernet] (irq=POLL) [ 294.605453] dwmac1000: Master AXI performs any burst length [ 294.611899] stmmaceth 1f060000.ethernet: invalid port speed [ 294.618229] stmmaceth 1f060000.ethernet eth1: No Safety Features support found [ 294.626412] stmmaceth 1f060000.ethernet eth1: No MAC Management Counters available [ 294.634912] stmmaceth 1f060000.ethernet eth1: IEEE 1588-2008 Advanced Timestamp supported [ 294.644380] stmmaceth 1f060000.ethernet eth1: registered PTP clock [ 294.651324] stmmaceth 1f060000.ethernet eth1: configuring for inband/rgmii-rxid link mode ... [ 298.772917] stmmaceth 1f060000.ethernet eth1: Link is Up - 1Gbps/Full - flow control rx/txQuoted 2 lines
So feel free to add:
Tested-by Serge Semin <[email protected]>Thanks.
Quoted 7 lines
Please note the warning: "stmmaceth 1f060000.ethernet: invalid port speed" in the log above. This is a false negative warning since my network devices isn't of MAC2MAC-type and there is no snps,ps-speed property in my dts. So having the
priv->hw.psset to zero should be fine. That said I guess we need to add the warning fix to the 14/14 patch which would permit theplat_stmmacenet_data::mac_port_sel_speedfield being zero.
Quoted 3 lines
I think this is a separate issue - one which exists even today with the stmmac driver as this code hasn't changed. Maybe it should be a separate patch targetting the net tree?
Ok. Tomorrow I'll submit the patch fixing that case.
Quoted 77 lines
Quoted 70 lines
Quoted 32 lines
Previous cover messages from earlier posts below:
This is version 3 of the series switching stmmac to use phylink PCS isntead of going behind phylink's back.
Changes since version 2:
- Adopted some of Serge's feedback.
- New patch: addingethqos_pcs_set_inband()for qcom-ethqos so we have one place to modify for AN control rather than many.
- New patch: pass thestmmac_privstructure into thepcs_set_ane()method.
- New patch: removepcs_get_adv_lp()early, as this is only for TBI and RTBI, support for which we dropped in an already merged patch.
- Providestmmac_pcsstructure to encapsulate the pointer tostmmac_priv, PCS MMIO address pointer andphylink_pcsstructure.
- Restructuredwmac_pcs_config()so we can eventually share code withdwmac_ctrl_ane().
- New patch: movedwmac_ctrl_ane()intostmmac_pcs.c, and share code.
- New patch: pass thestmmac_pcsstructure intodwmac_pcs_isr().
- New patch: similar to Serge's patch, rename the PCS registers, but useSTMMAC_PCS_as the prefix rather than justPCS_which is too generic.
- New patch: incorporate "net: stmmac: Activate Inband/PCS flag based on the selected iface" from Serge.On the subject of whether we should have two PCS instances, I experimented with that and have now decided against it. Instead,
dwmac_pcs_config()now tests whether we need to fiddle with the PCS control register or not.Quoted 4 lines
Note that I prefer not to have multiple layers of indirection, but instead prefer a library-style approach, which is why I haven't turned the PCS support into something that's self contained with a method in the MAC driver to grab the RGSMII status.
I understand the reason of your choice in this case. As a result a some part of my changes haven't been merged in into your series. But I deliberately selected the approach with having the simple PCS HW-interface callbacks utilized for a self-contained internal PCS implementation. Here is why:
1. Signify that the DW GMAC and DW QoS Eth internal PCSs are the same.
2. Reduce the amount of code.
3. Collects the entire PCS implementation in a single place which improves the code readability.
4. The PCS ops initialization is implemented in the same way as the PTP, MMC and EST (and likely FPE in some time in future), in thehwif.cand the interface/core callbacks in the dedicated files (stmmac_ptp.c,mmc_core.c,stmmac_est.c, etc). So the PCS implementation would be in general unified with what has been done for PTP/MMC/EST/etc.
5. ...Taking that into account I am still convinced that my approach worth to be implemented. Hope you won't mind, if after your series is merged in I'll submit another patch set which would introduce some of my PCS-changes not included into your patch set. Like this:
1. Move themac_device_infoinstance to being defined in thestmmac_privstructure (new patch, so to drop thestmmac_privpointer fromstmmac_pcs).
2. Introducestmmac_priv::pcsaddr(to have the PCS CSR base address defined in the same way as for PTP/MMC/EST/etc).
3. Provide the HWIF ops:stmmac_pcs_ops { pcs_get_config_reg; pcs_enable_irq; pcs_disable_irq; } for DW GMAC and DW QoS Eth.Quoted 5 lines
4. Move PCS implementation to
stmmac_pcs.c
5. Direct using theplat_stmmacenet_data::mac_port_sel_speedfield instead of themac_device_info::ps.
6. Some more cleanups like converting the structstmmac_hwif_entryfield from void-pointers to the typed-pointers, ...
Quoted 7 lines
I guessed that you would dig your heals in over this, and want to do it your own way despite all the points I raised against your patch series on my previous posting arguing against much of this.
So, at this point I give up with this patch series - clearly there is no room for discussion about the way forward, and you want to do it your way no matter what.
I actually thought that in general the approach implemented in my patches didn't meet much dislikes from your side. Just several notes which could be easily fixed in the next revisions.
Anyway thanks for understanding. I'll wait for your series to be merged in. Then I'll submit my patch set based on top of it (of course taking into account all the notes raised by you back then).
-Serge(y)
Quoted 4 lines
Signature · 3 lines
-- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Quoted 4 lines · Serge Semin
Quoted 3 lines · Russell King (Oracle)
Quoted 2 lines · Serge Semin
Hi Russell
...
Quoted 9 lines
Quoted 8 lines
I guessed that you would dig your heals in over this, and want to do it your own way despite all the points I raised against your patch series on my previous posting arguing against much of this.
So, at this point I give up with this patch series - clearly there is no room for discussion about the way forward, and you want to do it your way no matter what.
Quoted 8 lines
I actually thought that in general the approach implemented in my patches didn't meet much dislikes from your side. Just several notes which could be easily fixed in the next revisions.
Anyway thanks for understanding. I'll wait for your series to be merged in. Then I'll submit my patch set based on top of it (of course taking into account all the notes raised by you back then).
Hmmm, I'll poke the bears :)
Any chance this series will be rebased and sent out again? I really liked the direction of this and it seems a waste to end it at a stalemate here despite some differing opinions on the design and possible future changes.
I think we're all in agreement that stmmac's current PCS usage behind phylink's back is not good, and this is a massive improvement.
Thanks,
Andrew
Quoted 1 line
Hmmm, I'll poke the bears :)
Russell is away on 'medical leave', cataract surgery. It probably makes sense to wait until he is back.
Andrew
Quoted 5 lines · Andrew Lunn
Quoted 1 line
Hmmm, I'll poke the bears :)
Russell is away on 'medical leave', cataract surgery. It probably makes sense to wait until he is back.
Ahh yes, I forgot about that! Thanks for the reminder. I'll be patient then and hope is surgery and recovery is smooth :)
Thanks,
Andrew