net: qcom/emac: add ethtool support
Subsystems (3)
PATCH v2 1/1 net: qcom/emac: add ethtool support
Add support for some ethtool methods: get/set link settings, get/set message level, get statistics, get link status, get ring params, get pause params, and restart autonegotiation.
The code to collect the hardware statistics is moved into its own function so that it can be used by "get statistics" method.
---
Notes:
I don't trust my implementation of emac_get_pauseparam. I feel like I'm missing something.
v2: added emac_get_pauseparam and emac_get_ringparam
drivers/net/ethernet/qualcomm/emac/Makefile | 2 +- drivers/net/ethernet/qualcomm/emac/emac-ethtool.c | 185 ++++++++++++++++++++++ drivers/net/ethernet/qualcomm/emac/emac.c | 51 +++--- drivers/net/ethernet/qualcomm/emac/emac.h | 3 + 4 files changed, 220 insertions(+), 21 deletions(-) create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
drivers/net/ethernet/qualcomm/emac/Makefile +1 -1
@@ -4,6 +4,6 @@ obj-$(CONFIG_QCOM_EMAC) += qcom-emac.o -qcom-emac-objs := emac.o emac-mac.o emac-phy.o emac-sgmii.o \ +qcom-emac-objs := emac.o emac-mac.o emac-phy.o emac-sgmii.o emac-ethtool.o \ emac-sgmii-fsm9900.o emac-sgmii-qdf2432.o \ emac-sgmii-qdf2400.o
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c new file +185 -0
185 lines not on this page · raw message
drivers/net/ethernet/qualcomm/emac/emac.c +31 -20
82 lines not on this page · raw message
drivers/net/ethernet/qualcomm/emac/emac.h +3 -0
@@ -332,4 +332,7 @@ struct emac_adapter {void emac_reg_update32 (void __iomem *addr,u32 mask,u32 val);irqreturn_t emac_isr (int irq,void *data); +void emac_set_ethtool_ops (struct net_device *netdev); +void emac_update_hw_stats (struct emac_adapter *adpt); +#endif /* _EMAC_H_ */
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
David Miller
maintainerFrom: Timur Tabi <[email protected]>
Date: Fri, 6 Jan 2017 15:43:01 -0600
Quoted 7 lines
Add support for some ethtool methods: get/set link settings, get/set message level, get statistics, get link status, get ring params, get pause params, and restart autonegotiation.
The code to collect the hardware statistics is moved into its own function so that it can be used by "get statistics" method.
Quoted 8 lines
Signed-off-by Timur Tabi <[email protected]>---
Notes:
I don't trust my implementation ofemac_get_pauseparam. I feel like I'm missing something.v2: added
emac_get_pauseparamandemac_get_ringparam
This doesn't apply cleanly to net-next, please respin.
Quoted 4 lines · Timur Tabi
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c new file +4
-0+static void emac_get_pauseparam (struct net_device *netdev, +struct ethtool_pauseparam *pause) +{ +struct phy_device *phydev = netdev->phydev;
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c line 161
Quoted 10 lines
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c new file +10
-0+ +if (phydev) { +if (phydev->autoneg) + pause->autoneg =1 ; +if (phydev->pause) + pause->rx_pause =1 ; +if (phydev->pause != phydev->asym_pause) + pause->tx_pause =1 ; + } +}
I finally figured out why this code was bothering me.
This function works, as long as I do NOT implement set_pauseparam. That's because the driver always matches the pause frame support in the MAC with whatever the PHY is doing. Since the MAC and PHY are always in sync, I can use the PHY settings for get_pauseparam.
However, technically this is not correct. get_pauseparam is supposed to return the setting of the MAC, not the PHY. If I also implement set_pauseparam, which can force the MAC to ignore the PHY and enable/disable pause frames arbitrarily, then the above function is wrong.
Do I finally understand this correctly?
Signature · 3 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation.