From: Horatiu Vultur <horatiu.vultur@microchip.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <andrew@lunn.ch>, <hkallweit1@gmail.com>, <linux@armlinux.org.uk>,
<davem@davemloft.net>, <kuba@kernel.org>,
<richardcochran@gmail.com>, <UNGLinuxDriver@microchip.com>,
Horatiu Vultur <horatiu.vultur@microchip.com>
Subject: [RFC PATCH net-next 2/2] net: phy: micrel: Implement set/get_tunable
Date: Fri, 1 Apr 2022 11:39:09 +0200 [thread overview]
Message-ID: <20220401093909.3341836-3-horatiu.vultur@microchip.com> (raw)
In-Reply-To: <20220401093909.3341836-1-horatiu.vultur@microchip.com>
Implement set/get_tunable to set/get the PHY latencies.
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
drivers/net/phy/micrel.c | 93 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index fc53b71dc872..f537e61cb61d 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -99,6 +99,15 @@
#define PTP_TIMESTAMP_EN_PDREQ_ BIT(2)
#define PTP_TIMESTAMP_EN_PDRES_ BIT(3)
+#define PTP_RX_LATENCY_1000 0x0224
+#define PTP_TX_LATENCY_1000 0x0225
+
+#define PTP_RX_LATENCY_100 0x0222
+#define PTP_TX_LATENCY_100 0x0223
+
+#define PTP_RX_LATENCY_10 0x0220
+#define PTP_TX_LATENCY_10 0x0221
+
#define PTP_TX_PARSE_L2_ADDR_EN 0x0284
#define PTP_RX_PARSE_L2_ADDR_EN 0x0244
@@ -2591,6 +2600,88 @@ static int lan8814_ptp_probe_once(struct phy_device *phydev)
return 0;
}
+static void lan8814_get_latency(struct phy_device *phydev, u32 id, s32 *latency)
+{
+ switch (id) {
+ case ETHTOOL_PHY_LATENCY_RX_10MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_RX_LATENCY_10);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_10MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_TX_LATENCY_10);
+ break;
+ case ETHTOOL_PHY_LATENCY_RX_100MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_RX_LATENCY_100);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_100MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_TX_LATENCY_100);
+ break;
+ case ETHTOOL_PHY_LATENCY_RX_1000MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_RX_LATENCY_1000);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_1000MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_TX_LATENCY_1000);
+ break;
+ }
+}
+
+static int lan8814_get_tunable(struct phy_device *phydev,
+ struct ethtool_tunable *tuna, void *data)
+{
+ switch (tuna->id) {
+ case ETHTOOL_PHY_LATENCY_RX_10MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_10MBIT:
+ case ETHTOOL_PHY_LATENCY_RX_100MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_100MBIT:
+ case ETHTOOL_PHY_LATENCY_RX_1000MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_1000MBIT:
+ lan8814_get_latency(phydev, tuna->id, data);
+ return 0;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+static void lan8814_set_latency(struct phy_device *phydev, u32 id, s32 latency)
+{
+ switch (id) {
+ case ETHTOOL_PHY_LATENCY_RX_10MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_RX_LATENCY_10, latency);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_10MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_TX_LATENCY_10, latency);
+ break;
+ case ETHTOOL_PHY_LATENCY_RX_100MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_RX_LATENCY_100, latency);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_100MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_TX_LATENCY_100, latency);
+ break;
+ case ETHTOOL_PHY_LATENCY_RX_1000MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_RX_LATENCY_1000, latency);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_1000MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_TX_LATENCY_1000, latency);
+ break;
+ }
+}
+
+static int lan8814_set_tunable(struct phy_device *phydev,
+ struct ethtool_tunable *tuna, const void *data)
+{
+ switch (tuna->id) {
+ case ETHTOOL_PHY_LATENCY_RX_10MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_10MBIT:
+ case ETHTOOL_PHY_LATENCY_RX_100MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_100MBIT:
+ case ETHTOOL_PHY_LATENCY_RX_1000MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_1000MBIT:
+ lan8814_set_latency(phydev, tuna->id, *(const s32 *)data);
+ return 0;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
static int lan8814_config_init(struct phy_device *phydev)
{
int val;
@@ -2827,6 +2918,8 @@ static struct phy_driver ksphy_driver[] = {
.probe = lan8814_probe,
.soft_reset = genphy_soft_reset,
.read_status = ksz9031_read_status,
+ .get_tunable = lan8814_get_tunable,
+ .set_tunable = lan8814_set_tunable,
.get_sset_count = kszphy_get_sset_count,
.get_strings = kszphy_get_strings,
.get_stats = kszphy_get_stats,
--
2.33.0
prev parent reply other threads:[~2022-04-01 9:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 9:39 [RFC PATCH net-next 0/2] ethtool: Extend to set PHY latencies Horatiu Vultur
2022-04-01 9:39 ` [RFC PATCH net-next 1/2] ethtool: Extend to allow " Horatiu Vultur
2022-04-01 12:36 ` Andrew Lunn
2022-04-01 13:40 ` Horatiu Vultur
2022-04-01 9:39 ` Horatiu Vultur [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220401093909.3341836-3-horatiu.vultur@microchip.com \
--to=horatiu.vultur@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome