All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC 00/13] Ethernet PHY cable test support
@ 2019-06-12 16:05 Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 01/13] net: phy: Add cable test support to state machine Andrew Lunn
                   ` (14 more replies)
  0 siblings, 15 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

This patchset adds support for executing Ethernet PHY cable tests and
reporting the results back to user space. The Marvell PHY driver has
been extended so some of its cable test features can be used.

It builds upon the work of Michal Kubecek adding a netlink version of
ethtool. As such, that work needs to be merged first. However, with
Microchip posting their cable test work, i thought it a good idea to
post what i have.

A few examples:

./ethtool --cable-test lan6
Cable test for device lan6.
Pair: 0, result: OK
Pair: 1, result: OK
Pair: 2, result: OK
Pair: 3, result: OK

./ethtool --cable-test lan2
Cable test for device lan2.
Pair: 0, result: Open Circuit
Pair: 1, result: Open Circuit
Pair: 2, result: Open Circuit
Pair: 3, result: Open Circuit
Pair: 0, fault length: 14.40m
Pair: 1, fault length: 15.20m
Pair: 2, fault length: 14.40m
Pair: 3, fault length: 15.20m

./ethtool --cable-test lan5
Cable test for device lan5.
Pair: 0, result: OK
Pair: 1, result: OK
Pair: 2, result: Short within Pair
Pair: 3, result: Short within Pair
Pair: 2, fault length: 1.60m
Pair: 3, fault length: 0.80m

./ethtool --cable-test lan2 amplitude-graph
Cable test for device lan2.
Cable test Pulse: 1000mV
  Distance     Pair 0     Pair 1     Pair 2     Pair 3
         0       109         85         39         62
         1       -15         46         -7         31
         2         7          0          0         -7
         3         7          7          0         15
         4        15          7          7         15
         5        23          0          0          7
         6        15          0          0          7
         7        23          0          0          0
         8         7          0          0          7
         9         0          0          0          0
        10         0          0          0          0
        11         0          0          0          7
        12        -7          0          0          0
        13        -7          0         31          7
        14       359        140        273          7
        15       523        523        609        515
        16       601        570        632        585
        17       640        617        648        625
        18       562        625        179        640
        19       109        265         78        148
        20        85         93         70         70
        21        54         54         39         54
        22        46         46         31         39
        23        39         31         23         31
        24        15         23         15         23
        25         7         15         15         15
        26         0         15          7         15
        27         0          7          7          7
        28         0          7          7          7
        29         0          7          7          0
        30         7          0          7          0
        31         7          7          7          0
        32        -7          0        -23          7
        33       -15        -31        -39        -15
        34       -31        -39        -46        -23
        35       -39        -46        -39        -23
        36       -39        -46        -31        -39
        37       -23        -23        -23        -23
        38       -23        -23        -15        -15
        39       -15        -23        -15        -15


Andrew Lunn (13):
  net: phy: Add cable test support to state machine
  net: phy: Add support for polling cable test
  net: ethtool: netlink: Add support for triggering a cable test
  net: ethtool: Add Properties for cable test reports.
  net: ethtool: Make helpers public
  net: phy: Add infrastructure for reporting cable test results
  net: phy: cable test: Use request seq in broadcast reply
  net: phy: Add helpers for reporting test results
  net: phy: marvell: Add cable test support
  net: phy: Allow options to be passed to the cable test
  net: phy: Add helpers and attributes for amplitude graph
  net: phy: marvell: Add support for amplitude graph
  net: phy: Put interface into oper testing during cable test

 drivers/net/phy/Kconfig              |   1 +
 drivers/net/phy/marvell.c            | 374 +++++++++++++++++++++++++++
 drivers/net/phy/phy.c                | 215 +++++++++++++++
 include/linux/ethtool_netlink.h      |  12 +
 include/linux/phy.h                  |  49 ++++
 include/uapi/linux/ethtool_netlink.h |  87 +++++++
 net/ethtool/actions.c                |  84 ++++++
 net/ethtool/netlink.c                |  14 +-
 net/ethtool/netlink.h                |   7 +-
 9 files changed, 838 insertions(+), 5 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH RFC 01/13] net: phy: Add cable test support to state machine
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 02/13] net: phy: Add support for polling cable test Andrew Lunn
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

Running a cable test is desruptive to normal operation of the PHY and
can take a 5 to 10 seconds to complete. The RTNL lock cannot be held
for this amount of time, and add a new state to the state machine for
running a cable test.

The driver is expected to implement two functions. The first is used
to start a cable test. Once the test has started, it should return.

The second function is called once per second, or on interrupt to
check if the cable test is complete, and to allow the PHY to report
the status.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/phy.c | 65 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/phy.h   | 28 +++++++++++++++++++
 2 files changed, 93 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 984de987241c..65b13c74c158 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -15,6 +15,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
+#include <linux/netlink.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/mm.h>
@@ -42,6 +43,7 @@ static const char *phy_state_to_str(enum phy_state st)
 	PHY_STATE_STR(RUNNING)
 	PHY_STATE_STR(NOLINK)
 	PHY_STATE_STR(FORCING)
+	PHY_STATE_STR(CABLETEST)
 	PHY_STATE_STR(HALTED)
 	PHY_STATE_STR(RESUMING)
 	}
@@ -465,6 +467,51 @@ static void phy_trigger_machine(struct phy_device *phydev)
 	phy_queue_state_machine(phydev, 0);
 }
 
+static void phy_cable_test_abort(struct phy_device *phydev)
+{
+	genphy_soft_reset(phydev);
+}
+
+int phy_start_cable_test(struct phy_device *phydev,
+			 struct netlink_ext_ack *extack)
+{
+	int err;
+
+	if (!(phydev->drv &&
+	      phydev->drv->cable_test_start &&
+	      phydev->drv->cable_test_get_status)) {
+		NL_SET_ERR_MSG(extack,
+			       "PHY driver does not support cable testing");
+		return -EOPNOTSUPP;
+	}
+
+	mutex_lock(&phydev->lock);
+	if (phydev->state < PHY_UP ||
+	    phydev->state >= PHY_CABLETEST) {
+		NL_SET_ERR_MSG(extack,
+			       "PHY not configured. Try setting interface up");
+		err = -EBUSY;
+		goto out;
+	}
+
+	/* Mark the carrier down until the test is complete */
+	phy_link_down(phydev, true);
+
+	err = phydev->drv->cable_test_start(phydev);
+	if (err) {
+		phy_link_up(phydev);
+		goto out;
+	}
+
+	phydev->state = PHY_CABLETEST;
+
+out:
+	mutex_unlock(&phydev->lock);
+
+	return err;
+}
+EXPORT_SYMBOL(phy_start_cable_test);
+
 static int phy_config_aneg(struct phy_device *phydev)
 {
 	if (phydev->drv->config_aneg)
@@ -810,6 +857,9 @@ void phy_stop(struct phy_device *phydev)
 
 	mutex_lock(&phydev->lock);
 
+	if (phydev->state == PHY_CABLETEST)
+		phy_cable_test_abort(phydev);
+
 	if (phy_interrupt_is_valid(phydev))
 		phy_disable_interrupts(phydev);
 
@@ -881,6 +931,7 @@ void phy_state_machine(struct work_struct *work)
 			container_of(dwork, struct phy_device, state_queue);
 	bool needs_aneg = false, do_suspend = false;
 	enum phy_state old_state;
+	bool finished = false;
 	int err = 0;
 
 	mutex_lock(&phydev->lock);
@@ -914,6 +965,20 @@ void phy_state_machine(struct work_struct *work)
 			phy_link_down(phydev, false);
 		}
 		break;
+	case PHY_CABLETEST:
+		err = phydev->drv->cable_test_get_status(phydev, &finished);
+		if (err) {
+			phy_cable_test_abort(phydev);
+			needs_aneg = true;
+			phydev->state = PHY_UP;
+			break;
+		}
+
+		if (finished) {
+			needs_aneg = true;
+			phydev->state = PHY_UP;
+		}
+		break;
 	case PHY_HALTED:
 		if (phydev->link) {
 			phydev->link = 0;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 0f9552b17ee7..2531684f507d 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -20,6 +20,7 @@
 #include <linux/spinlock.h>
 #include <linux/ethtool.h>
 #include <linux/linkmode.h>
+#include <linux/netlink.h>
 #include <linux/mdio.h>
 #include <linux/mii.h>
 #include <linux/module.h>
@@ -306,6 +307,12 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
  * - irq or timer will set NOLINK if link goes down
  * - phy_stop moves to HALTED
  *
+ * CABLETEST: PHY is performing a cable test. Packet reception/sending
+ * is not expected to work, carrier will be indicated as down. PHY will be
+ * poll once per second, or on interrupt for it current state.
+ * Once complete, move to UP to restart the PHY.
+ * - phy_stop aborts the running test and moves to HALTED
+ *
  * HALTED: PHY is up, but no polling or interrupts are done. Or
  * PHY is in an error state.
  *
@@ -324,6 +331,7 @@ enum phy_state {
 	PHY_RUNNING,
 	PHY_NOLINK,
 	PHY_FORCING,
+	PHY_CABLETEST,
 	PHY_RESUMING
 };
 
@@ -626,6 +634,13 @@ struct phy_driver {
 	int (*module_eeprom)(struct phy_device *dev,
 			     struct ethtool_eeprom *ee, u8 *data);
 
+	/* Start a cable test */
+	int (*cable_test_start)(struct phy_device *dev);
+	/* Once per second, or on interrupt, request the status of the
+	 * test.
+	 */
+	int (*cable_test_get_status)(struct phy_device *dev, bool *finished);
+
 	/* Get statistics from the phy using ethtool */
 	int (*get_sset_count)(struct phy_device *dev);
 	void (*get_strings)(struct phy_device *dev, u8 *data);
@@ -1050,6 +1065,19 @@ int phy_speed_up(struct phy_device *phydev);
 int phy_restart_aneg(struct phy_device *phydev);
 int phy_reset_after_clk_enable(struct phy_device *phydev);
 
+#if IS_ENABLED(CONFIG_PHYLIB)
+int phy_start_cable_test(struct phy_device *phydev,
+			 struct netlink_ext_ack *extack);
+#else
+static inline
+int phy_start_cable_test(struct phy_device *phydev,
+			 struct netlink_ext_ack *extack)
+{
+	NL_SET_ERR_MSG(extack, "Kernel not compiled with PHYLIB support");
+	return -EOPNOTSUPP;
+}
+#endif
+
 static inline void phy_device_reset(struct phy_device *phydev, int value)
 {
 	mdio_device_reset(&phydev->mdio, value);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 02/13] net: phy: Add support for polling cable test
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 01/13] net: phy: Add cable test support to state machine Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 03/13] net: ethtool: netlink: Add support for triggering a " Andrew Lunn
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

Some PHYs are not capable of generating interrupts when a cable test
finished. They do however support interrupts for normal operations,
like link up/down. As such, the PHY state machine would normally not
poll the PHY.

Add support for indicating the PHY state machine must poll the PHY
when performing a cable test.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/phy.c | 2 ++
 include/linux/phy.h   | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 65b13c74c158..dbd4484f04be 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -505,6 +505,8 @@ int phy_start_cable_test(struct phy_device *phydev,
 
 	phydev->state = PHY_CABLETEST;
 
+	if (phy_polling_mode(phydev))
+		phy_trigger_machine(phydev);
 out:
 	mutex_unlock(&phydev->lock);
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 2531684f507d..0dc6adc73a01 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -76,6 +76,7 @@ extern const int phy_10gbit_features_array[1];
 
 #define PHY_IS_INTERNAL		0x00000001
 #define PHY_RST_AFTER_CLK_EN	0x00000002
+#define PHY_POLL_CABLE_TEST	0x00000004
 #define MDIO_DEVICE_IS_PHY	0x80000000
 
 /* Interface Mode definitions */
@@ -950,6 +951,10 @@ static inline bool phy_interrupt_is_valid(struct phy_device *phydev)
  */
 static inline bool phy_polling_mode(struct phy_device *phydev)
 {
+	if (phydev->state == PHY_CABLETEST)
+		if (phydev->drv->flags & PHY_POLL_CABLE_TEST)
+			return true;
+
 	return phydev->irq == PHY_POLL;
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 03/13] net: ethtool: netlink: Add support for triggering a cable test
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 01/13] net: phy: Add cable test support to state machine Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 02/13] net: phy: Add support for polling cable test Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 04/13] net: ethtool: Add Properties for cable test reports Andrew Lunn
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

Add new ethtool netlink calls to trigger the starting of a PHY cable
test.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/Kconfig              |  1 +
 include/uapi/linux/ethtool_netlink.h | 12 +++++
 net/ethtool/actions.c                | 77 ++++++++++++++++++++++++++++
 net/ethtool/netlink.c                |  6 +++
 net/ethtool/netlink.h                |  4 ++
 5 files changed, 100 insertions(+)

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index d6299710d634..fc2be56fd2f8 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -208,6 +208,7 @@ menuconfig PHYLIB
 	tristate "PHY Device support and infrastructure"
 	depends on NETDEVICES
 	select MDIO_DEVICE
+	select ETHTOOL_NETLINK
 	help
 	  Ethernet controllers are usually attached to PHY
 	  devices.  This option provides infrastructure for
diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h
index c6686ebb35b2..e9d0d6fac23b 100644
--- a/include/uapi/linux/ethtool_netlink.h
+++ b/include/uapi/linux/ethtool_netlink.h
@@ -27,6 +27,7 @@ enum {
 	ETHNL_CMD_ACT_RESET,
 	ETHNL_CMD_GET_RXFLOW,
 	ETHNL_CMD_SET_RXFLOW,
+	ETHNL_CMD_ACT_CABLE_TEST,
 
 	__ETHNL_CMD_CNT,
 	ETHNL_CMD_MAX = (__ETHNL_CMD_CNT - 1)
@@ -106,6 +107,7 @@ enum {
 	ETHTOOL_A_EVENT_NEWDEV,			/* nest - ETHTOOL_A_NEWDEV_* */
 	ETHTOOL_A_EVENT_DELDEV,			/* nest - ETHTOOL_A_DELDEV_* */
 	ETHTOOL_A_EVENT_RENAMEDEV,		/* nest - ETHTOOL_A_RENAMEDEV_* */
+	ETHTOOL_A_EVENT_CABLE_TEST,		/* nest - ETHTOOL_A_CABLE_TEST_* */
 
 	__ETHTOOL_A_EVENT_CNT,
 	ETHTOOL_A_EVENT_MAX = (__ETHTOOL_A_EVENT_CNT - 1)
@@ -504,6 +506,16 @@ enum {
 	ETHTOOL_A_RXHASHOPT_MAX = (__ETHTOOL_A_RXHASHOPT_CNT - 1)
 };
 
+/* ACT_CABLE_TEST */
+
+enum {
+	ETHTOOL_A_CABLE_TEST_UNSPEC,
+	ETHTOOL_A_CABLE_TEST_DEV,		/* nest - ETHTOOL_A_DEV_* */
+
+	__ETHTOOL_A_CABLE_TEST_CNT,
+	ETHTOOL_A_CABLE_TEST_MAX = (__ETHTOOL_A_CABLE_TEST_CNT - 1)
+};
+
 enum {
 	ETHTOOL_A_INDTBL_UNSPEC,
 	ETHTOOL_A_INDTBL_BLOCK32,		/* nest - ETH_ITBLK_* */
diff --git a/net/ethtool/actions.c b/net/ethtool/actions.c
index 1fa630cf303f..8a26ae1b2ada 100644
--- a/net/ethtool/actions.c
+++ b/net/ethtool/actions.c
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 
+#include <linux/phy.h>
 #include "netlink.h"
 #include "common.h"
 #include "bitset.h"
@@ -375,3 +376,79 @@ int ethnl_act_reset(struct sk_buff *skb, struct genl_info *info)
 		GENL_SET_ERR_MSG(info, "failed to send reply message");
 	return ret;
 }
+
+/* ACT_CABLE_TEST */
+
+static const struct
+nla_policy cable_test_policy[ETHTOOL_A_CABLE_TEST_MAX + 1] = {
+	[ETHTOOL_A_CABLE_TEST_UNSPEC]	= { .type = NLA_REJECT },
+	[ETHTOOL_A_CABLE_TEST_DEV]		= { .type = NLA_NESTED },
+};
+
+void ethnl_cable_test_notify(struct net_device *dev,
+			     struct netlink_ext_ack *extack, unsigned int cmd,
+			     u32 req_mask, const void *data)
+{
+	struct sk_buff *skb;
+	void *msg_payload;
+	int msg_len;
+	int ret;
+
+	msg_len = dev_ident_size();
+	skb = genlmsg_new(msg_len, GFP_KERNEL);
+	if (!skb)
+		return;
+
+	msg_payload = ethnl_bcastmsg_put(skb, ETHNL_CMD_ACT_CABLE_TEST);
+	if (!msg_payload)
+		goto err_skb;
+
+	ret = ethnl_fill_dev(skb, dev, ETHTOOL_A_CABLE_TEST_DEV);
+	if (ret < 0)
+		goto err_skb;
+
+	genlmsg_end(skb, msg_payload);
+	ethnl_multicast(skb, dev);
+	return;
+
+err_skb:
+	nlmsg_free(skb);
+}
+
+int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info)
+{
+	struct nlattr *tb[ETHTOOL_A_CABLE_TEST_MAX + 1];
+	struct net_device *dev;
+	int ret;
+
+	ret = nlmsg_parse(info->nlhdr, GENL_HDRLEN, tb,
+			  ETHTOOL_A_CABLE_TEST_MAX, cable_test_policy,
+			  info->extack);
+	if (ret < 0)
+		return ret;
+
+	dev = ethnl_dev_get(info, tb[ETHTOOL_A_CABLE_TEST_DEV]);
+	if (IS_ERR(dev))
+		return PTR_ERR(dev);
+
+	ret = -EOPNOTSUPP;
+	if (!dev->phydev)
+		goto out_dev;
+
+	rtnl_lock();
+	ret = ethnl_before_ops(dev);
+	if (ret < 0)
+		goto out_rtnl;
+
+	ret = phy_start_cable_test(dev->phydev, info->extack);
+	ethnl_after_ops(dev);
+
+	if (ret == 0)
+		ethtool_notify(dev, NULL, ETHNL_CMD_ACT_CABLE_TEST, 0, NULL);
+
+out_rtnl:
+	rtnl_unlock();
+out_dev:
+	dev_put(dev);
+	return ret;
+}
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 540c92091fe9..894dc81536c9 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -589,6 +589,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
 	[ETHNL_CMD_ACT_PHYS_ID]		= ethnl_physid_notify,
 	[ETHNL_CMD_ACT_RESET]		= ethnl_reset_notify,
 	[ETHNL_CMD_SET_RXFLOW]		= ethnl_rxflow_notify,
+	[ETHNL_CMD_ACT_CABLE_TEST]	= ethnl_cable_test_notify,
 };
 
 void ethtool_notify(struct net_device *dev, struct netlink_ext_ack *extack,
@@ -747,6 +748,11 @@ static const struct genl_ops ethtool_genl_ops[] = {
 		.flags	= GENL_UNS_ADMIN_PERM,
 		.doit	= ethnl_set_rxflow,
 	},
+	{
+		.cmd	= ETHNL_CMD_ACT_CABLE_TEST,
+		.flags	= GENL_UNS_ADMIN_PERM,
+		.doit	= ethnl_act_cable_test,
+	},
 };
 
 static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index cb7dce82cc7e..4e7b40a8401d 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -269,6 +269,7 @@ int ethnl_set_rxflow(struct sk_buff *skb, struct genl_info *info);
 int ethnl_act_nway_rst(struct sk_buff *skb, struct genl_info *info);
 int ethnl_act_phys_id(struct sk_buff *skb, struct genl_info *info);
 int ethnl_act_reset(struct sk_buff *skb, struct genl_info *info);
+int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info);
 
 /* notify handlers */
 
@@ -281,5 +282,8 @@ void ethnl_reset_notify(struct net_device *dev, struct netlink_ext_ack *extack,
 			unsigned int cmd, u32 req_mask, const void *data);
 void ethnl_rxflow_notify(struct net_device *dev, struct netlink_ext_ack *extack,
 			 unsigned int cmd, u32 req_mask, const void *data);
+void ethnl_cable_test_notify(struct net_device *dev,
+			     struct netlink_ext_ack *extack,
+			     unsigned int cmd, u32 req_mask, const void *data);
 
 #endif /* _NET_ETHTOOL_NETLINK_H */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 04/13] net: ethtool: Add Properties for cable test reports.
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (2 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 03/13] net: ethtool: netlink: Add support for triggering a " Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 05/13] net: ethtool: Make helpers public Andrew Lunn
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

Add the attributes needed to report cable test results to userspace.
The reports are expected to be per twisted pair. A nested property per
pair can report the result of the cable test, and length of the cable
to any fault. More attributes can be added later for other types of
fault or measurement.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 include/uapi/linux/ethtool_netlink.h | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h
index e9d0d6fac23b..aac76a26f97b 100644
--- a/include/uapi/linux/ethtool_netlink.h
+++ b/include/uapi/linux/ethtool_netlink.h
@@ -506,6 +506,60 @@ enum {
 	ETHTOOL_A_RXHASHOPT_MAX = (__ETHTOOL_A_RXHASHOPT_CNT - 1)
 };
 
+/* Cable test CMD_EVENT for reporting results */
+
+enum {
+	ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC,
+	ETHTOOL_A_CABLE_RESULT_CODE_OK,
+	ETHTOOL_A_CABLE_RESULT_CODE_OPEN,
+	ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT,
+	ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT,
+};
+
+enum {
+	ETHTOOL_A_CABLE_PAIR_0,
+	ETHTOOL_A_CABLE_PAIR_1,
+	ETHTOOL_A_CABLE_PAIR_2,
+	ETHTOOL_A_CABLE_PAIR_3,
+};
+
+enum {
+	ETHTOOL_A_CABLE_RESULT_UNSPEC,
+	ETHTOOL_A_CABLE_RESULT_PAIR,		/* u8 */
+	ETHTOOL_A_CABLE_RESULT_CODE,		/* u8 ETHTOOL_A_CABLE_RESULT_CODE_ */
+
+	__ETHTOOL_A_CABLE_RESULT_CNT,
+	ETHTOOL_A_CABLE_RESULT_MAX = (__ETHTOOL_A_CABLE_RESULT_CNT - 1)
+};
+
+enum {
+	ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC,
+	ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR,	/* u8 */
+	ETHTOOL_A_CABLE_FAULT_LENGTH_CM,	/* u16 */
+
+	__ETHTOOL_A_CABLE_FAULT_LENGTH_CNT,
+	ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = (__ETHTOOL_A_CABLE_FAULT_LENGTH_CNT - 1)
+};
+
+enum {
+	ETHTOOL_A_CABLE_LENGTH_UNSPEC,
+	ETHTOOL_A_CABLE_LENGTH_PAIR,		/* u8 */
+	ETHTOOL_A_CABLE_LENGTH_CM,		/* u16 */
+
+	__ETHTOOL_A_CABLE_LENGTH_CNT,
+	ETHTOOL_A_CABLE_LENGTH_MAX = (__ETHTOOL_A_CABLE_LENGTH_CNT - 1)
+};
+
+enum {
+	ETHTOOL_A_CABLE_TEST_EVENT_UNSPEC,
+	ETHTOOL_A_CABLE_TEST_EVENT_DEV,		/* nest - ETHTOOL_A_DEV_* */
+	ETHTOOL_A_CABLE_TEST_EVENT_RESULT,	/* nest - ETHTOOL_A_CABLE_RESULT_ */
+	ETHTOOL_A_CABLE_TEST_EVENT_FAULT_LENGTH,/* nest - ETHTOOL_A_CABLE_FAULT_LENGTH_ */
+
+	__ETHTOOL_A_CABLE_TEST_EVENT_CNT,
+	ETHTOOL_A_CABLE_TEST_EVENT_MAX = (__ETHTOOL_A_CABLE_TEST_EVENT_CNT - 1)
+};
+
 /* ACT_CABLE_TEST */
 
 enum {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 05/13] net: ethtool: Make helpers public
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (3 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 04/13] net: ethtool: Add Properties for cable test reports Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 06/13] net: phy: Add infrastructure for reporting cable test results Andrew Lunn
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

Move Some helpers for building ethtool netlink messages into public
locations so drivers can make use of them.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 include/linux/ethtool_netlink.h | 11 +++++++++++
 net/ethtool/netlink.h           |  3 ---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/ethtool_netlink.h b/include/linux/ethtool_netlink.h
index 288e90f4dbb9..7d98592cd8a1 100644
--- a/include/linux/ethtool_netlink.h
+++ b/include/linux/ethtool_netlink.h
@@ -6,6 +6,7 @@
 #include <uapi/linux/ethtool_netlink.h>
 #include <linux/ethtool.h>
 #include <linux/netdevice.h>
+#include <net/netlink.h>
 
 #define __ETHTOOL_LINK_MODE_MASK_NWORDS \
 	DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32)
@@ -20,4 +21,14 @@ struct ethtool_rxflow_notification_info {
 	u32	flow_type;
 };
 
+static inline struct nlattr *ethnl_nest_start(struct sk_buff *skb,
+					      int attrtype)
+{
+	return nla_nest_start(skb, attrtype | NLA_F_NESTED);
+}
+
+int ethnl_fill_dev(struct sk_buff *msg, struct net_device *dev, u16 attrtype);
+void *ethnl_bcastmsg_put(struct sk_buff *skb, u8 cmd);
+int ethnl_multicast(struct sk_buff *skb, struct net_device *dev);
+
 #endif /* _LINUX_ETHTOOL_NETLINK_H_ */
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 4e7b40a8401d..d54fe7b6dac2 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -20,13 +20,10 @@ extern const char *const link_mode_names[];
 extern const char *const reset_flag_names[];
 
 struct net_device *ethnl_dev_get(struct genl_info *info, struct nlattr *nest);
-int ethnl_fill_dev(struct sk_buff *msg, struct net_device *dev, u16 attrtype);
 
 struct sk_buff *ethnl_reply_init(size_t payload, struct net_device *dev, u8 cmd,
 				 u16 dev_attrtype, struct genl_info *info,
 				 void **ehdrp);
-void *ethnl_bcastmsg_put(struct sk_buff *skb, u8 cmd);
-int ethnl_multicast(struct sk_buff *skb, struct net_device *dev);
 
 #if BITS_PER_LONG == 64 && defined(__BIG_ENDIAN)
 void ethnl_bitmap_to_u32(unsigned long *bitmap, unsigned int nwords);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 06/13] net: phy: Add infrastructure for reporting cable test results
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (4 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 05/13] net: ethtool: Make helpers public Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 07/13] net: phy: cable test: Use request seq in broadcast reply Andrew Lunn
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

Provide infrastrucutre for PHY drivers to report the cable test
results.  A netlink skb is associated to the phydev. Helpers will be
added which can add results to this skb. Once the test has finished
the results are sent to user space.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/phy.c | 44 +++++++++++++++++++++++++++++++++++++++++--
 include/linux/phy.h   |  5 +++++
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index dbd4484f04be..db8a5957acdd 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -22,6 +22,7 @@
 #include <linux/module.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
+#include <linux/ethtool_netlink.h>
 #include <linux/phy.h>
 #include <linux/phy_led_triggers.h>
 #include <linux/workqueue.h>
@@ -29,6 +30,9 @@
 #include <linux/io.h>
 #include <linux/uaccess.h>
 #include <linux/atomic.h>
+#include <net/netlink.h>
+#include <net/genetlink.h>
+#include <net/sock.h>
 
 #define PHY_STATE_STR(_state)			\
 	case PHY_##_state:			\
@@ -467,15 +471,25 @@ static void phy_trigger_machine(struct phy_device *phydev)
 	phy_queue_state_machine(phydev, 0);
 }
 
+static void phy_cable_test_finished(struct phy_device *phydev)
+{
+	nla_nest_end(phydev->skb, phydev->nest);
+	genlmsg_end(phydev->skb, phydev->ehdr);
+
+	ethnl_multicast(phydev->skb, phydev->attached_dev);
+}
+
 static void phy_cable_test_abort(struct phy_device *phydev)
 {
+	phy_cable_test_finished(phydev);
 	genphy_soft_reset(phydev);
 }
 
 int phy_start_cable_test(struct phy_device *phydev,
 			 struct netlink_ext_ack *extack)
 {
-	int err;
+	int err = -ENOMEM;
+	int ret;
 
 	if (!(phydev->drv &&
 	      phydev->drv->cable_test_start &&
@@ -494,19 +508,44 @@ int phy_start_cable_test(struct phy_device *phydev,
 		goto out;
 	}
 
+	phydev->skb = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	if (!phydev->skb)
+		goto out;
+
+	phydev->ehdr = ethnl_bcastmsg_put(phydev->skb, ETHNL_CMD_EVENT);
+	if (!phydev->ehdr)
+		goto out_free;
+
+	phydev->nest = ethnl_nest_start(phydev->skb,
+					ETHTOOL_A_EVENT_CABLE_TEST);
+	if (!phydev->nest)
+		goto out_free;
+
+	ret = ethnl_fill_dev(phydev->skb, phydev->attached_dev,
+			     ETHTOOL_A_CABLE_TEST_DEV);
+	if (ret < 0)
+		goto out_free;
+
 	/* Mark the carrier down until the test is complete */
 	phy_link_down(phydev, true);
 
 	err = phydev->drv->cable_test_start(phydev);
 	if (err) {
 		phy_link_up(phydev);
-		goto out;
+		goto out_free;
 	}
 
 	phydev->state = PHY_CABLETEST;
 
 	if (phy_polling_mode(phydev))
 		phy_trigger_machine(phydev);
+
+	mutex_unlock(&phydev->lock);
+
+	return 0;
+
+out_free:
+	nlmsg_free(phydev->skb);
 out:
 	mutex_unlock(&phydev->lock);
 
@@ -977,6 +1016,7 @@ void phy_state_machine(struct work_struct *work)
 		}
 
 		if (finished) {
+			phy_cable_test_finished(phydev);
 			needs_aneg = true;
 			phydev->state = PHY_UP;
 		}
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 0dc6adc73a01..da8cc97b55dc 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -450,6 +450,11 @@ struct phy_device {
 	/* For use by PHYs to maintain extra state */
 	void *priv;
 
+	/* Reporting cable test results */
+	struct sk_buff *skb;
+	void *ehdr;
+	struct nlattr *nest;
+
 	/* Interrupt and Polling infrastructure */
 	struct delayed_work state_queue;
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 07/13] net: phy: cable test: Use request seq in broadcast reply
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (5 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 06/13] net: phy: Add infrastructure for reporting cable test results Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 08/13] net: phy: Add helpers for reporting test results Andrew Lunn
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

An ethtool netlink action is used to start the cable test. Use the
sequence number from this action in the multicast later used to send
the results of the cable test, so that the results can be match back
to the request.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/phy.c           | 5 +++--
 include/linux/ethtool_netlink.h | 1 +
 include/linux/phy.h             | 6 ++++--
 net/ethtool/actions.c           | 3 ++-
 net/ethtool/netlink.c           | 8 ++++++--
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index db8a5957acdd..3c614639ce20 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -486,7 +486,7 @@ static void phy_cable_test_abort(struct phy_device *phydev)
 }
 
 int phy_start_cable_test(struct phy_device *phydev,
-			 struct netlink_ext_ack *extack)
+			 struct netlink_ext_ack *extack, u32 seq)
 {
 	int err = -ENOMEM;
 	int ret;
@@ -512,7 +512,8 @@ int phy_start_cable_test(struct phy_device *phydev,
 	if (!phydev->skb)
 		goto out;
 
-	phydev->ehdr = ethnl_bcastmsg_put(phydev->skb, ETHNL_CMD_EVENT);
+	phydev->ehdr = ethnl_bcastmsg_put_seq(phydev->skb, ETHNL_CMD_EVENT,
+					      seq);
 	if (!phydev->ehdr)
 		goto out_free;
 
diff --git a/include/linux/ethtool_netlink.h b/include/linux/ethtool_netlink.h
index 7d98592cd8a1..66a91e629694 100644
--- a/include/linux/ethtool_netlink.h
+++ b/include/linux/ethtool_netlink.h
@@ -29,6 +29,7 @@ static inline struct nlattr *ethnl_nest_start(struct sk_buff *skb,
 
 int ethnl_fill_dev(struct sk_buff *msg, struct net_device *dev, u16 attrtype);
 void *ethnl_bcastmsg_put(struct sk_buff *skb, u8 cmd);
+void *ethnl_bcastmsg_put_seq(struct sk_buff *skb, u8 cmd, u32 seq);
 int ethnl_multicast(struct sk_buff *skb, struct net_device *dev);
 
 #endif /* _LINUX_ETHTOOL_NETLINK_H_ */
diff --git a/include/linux/phy.h b/include/linux/phy.h
index da8cc97b55dc..cea151c66ac1 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1077,11 +1077,13 @@ int phy_reset_after_clk_enable(struct phy_device *phydev);
 
 #if IS_ENABLED(CONFIG_PHYLIB)
 int phy_start_cable_test(struct phy_device *phydev,
-			 struct netlink_ext_ack *extack);
+			 struct netlink_ext_ack *extack,
+			 u32 seq);
 #else
 static inline
 int phy_start_cable_test(struct phy_device *phydev,
-			 struct netlink_ext_ack *extack)
+			 struct netlink_ext_ack *extack,
+			 u32 seq)
 {
 	NL_SET_ERR_MSG(extack, "Kernel not compiled with PHYLIB support");
 	return -EOPNOTSUPP;
diff --git a/net/ethtool/actions.c b/net/ethtool/actions.c
index 8a26ae1b2ada..8595cc27d532 100644
--- a/net/ethtool/actions.c
+++ b/net/ethtool/actions.c
@@ -440,7 +440,8 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info)
 	if (ret < 0)
 		goto out_rtnl;
 
-	ret = phy_start_cable_test(dev->phydev, info->extack);
+	ret = phy_start_cable_test(dev->phydev, info->extack, info->snd_seq);
+
 	ethnl_after_ops(dev);
 
 	if (ret == 0)
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 894dc81536c9..9d97de1c86aa 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -240,10 +240,14 @@ struct sk_buff *ethnl_reply_init(size_t payload, struct net_device *dev, u8 cmd,
 	return NULL;
 }
 
+void *ethnl_bcastmsg_put_seq(struct sk_buff *skb, u8 cmd, u32 seq)
+{
+	return genlmsg_put(skb, 0, seq, &ethtool_genl_family, 0, cmd);
+}
+
 void *ethnl_bcastmsg_put(struct sk_buff *skb, u8 cmd)
 {
-	return genlmsg_put(skb, 0, ++ethnl_bcast_seq, &ethtool_genl_family, 0,
-			   cmd);
+	return ethnl_bcastmsg_put_seq(skb, cmd, ++ethnl_bcast_seq);
 }
 
 int ethnl_multicast(struct sk_buff *skb, struct net_device *dev)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 08/13] net: phy: Add helpers for reporting test results
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (6 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 07/13] net: phy: cable test: Use request seq in broadcast reply Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 09/13] net: phy: marvell: Add cable test support Andrew Lunn
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

The PHY drivers can use these helpers for reporting the results. The
results get translated into netlink attributes which are added to the
pre-allocated skbuf.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/phy.c | 47 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/phy.h   |  4 ++++
 2 files changed, 51 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 3c614639ce20..6540523d773a 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -485,6 +485,53 @@ static void phy_cable_test_abort(struct phy_device *phydev)
 	genphy_soft_reset(phydev);
 }
 
+int phy_cable_test_result(struct phy_device *phydev, u8 pair, u16 result)
+{
+	struct nlattr *nest;
+	int ret = -EMSGSIZE;
+
+	nest = ethnl_nest_start(phydev->skb, ETHTOOL_A_CABLE_TEST_EVENT_RESULT);
+	if (!nest)
+		return -EMSGSIZE;
+
+	if (nla_put_u8(phydev->skb, ETHTOOL_A_CABLE_RESULT_PAIR, pair))
+		goto err;
+	if (nla_put_u8(phydev->skb, ETHTOOL_A_CABLE_RESULT_CODE, result))
+		goto err;
+
+	nla_nest_end(phydev->skb, nest);
+	return 0;
+
+err:
+	nla_nest_cancel(phydev->skb, nest);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phy_cable_test_result);
+
+int phy_cable_test_fault_length(struct phy_device *phydev, u8 pair, u16 cm)
+{
+	struct nlattr *nest;
+	int ret = -EMSGSIZE;
+
+	nest = ethnl_nest_start(phydev->skb,
+				ETHTOOL_A_CABLE_TEST_EVENT_FAULT_LENGTH);
+	if (!nest)
+		return -EMSGSIZE;
+
+	if (nla_put_u8(phydev->skb, ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR, pair))
+		goto err;
+	if (nla_put_u16(phydev->skb, ETHTOOL_A_CABLE_FAULT_LENGTH_CM, cm))
+		goto err;
+
+	nla_nest_end(phydev->skb, nest);
+	return 0;
+
+err:
+	nla_nest_cancel(phydev->skb, nest);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phy_cable_test_fault_length);
+
 int phy_start_cable_test(struct phy_device *phydev,
 			 struct netlink_ext_ack *extack, u32 seq)
 {
diff --git a/include/linux/phy.h b/include/linux/phy.h
index cea151c66ac1..23c18583ea07 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1090,6 +1090,10 @@ int phy_start_cable_test(struct phy_device *phydev,
 }
 #endif
 
+int phy_cable_test_result(struct phy_device *phydev, u8 pair, u16 result);
+int phy_cable_test_fault_length(struct phy_device *phydev, u8 pair,
+				u16 cm);
+
 static inline void phy_device_reset(struct phy_device *phydev, int value)
 {
 	mdio_device_reset(&phydev->mdio, value);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 09/13] net: phy: marvell: Add cable test support
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (7 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 08/13] net: phy: Add helpers for reporting test results Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-13  3:08   ` Florian Fainelli
  2019-06-12 16:05 ` [PATCH RFC 10/13] net: phy: Allow options to be passed to the cable test Andrew Lunn
                   ` (5 subsequent siblings)
  14 siblings, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

The Marvell PHYs have a couple of different register sets for
performing cable tests. Page 7 provides the simplest to use. However,
it does not provide cable length, only length to a fault, when there
is a fault.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/marvell.c | 198 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 198 insertions(+)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index a7796134e3be..96354513daba 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -35,6 +35,7 @@
 #include <linux/io.h>
 #include <asm/irq.h>
 #include <linux/uaccess.h>
+#include <uapi/linux/ethtool_netlink.h>
 
 #define MII_MARVELL_PHY_PAGE		22
 #define MII_MARVELL_COPPER_PAGE		0x00
@@ -42,6 +43,7 @@
 #define MII_MARVELL_MSCR_PAGE		0x02
 #define MII_MARVELL_LED_PAGE		0x03
 #define MII_MARVELL_MISC_TEST_PAGE	0x06
+#define MII_MARVELL_VCT7_PAGE		0x07
 #define MII_MARVELL_WOL_PAGE		0x11
 
 #define MII_M1011_IEVENT		0x13
@@ -156,6 +158,36 @@
 #define MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII	0x1	/* SGMII to copper */
 #define MII_88E1510_GEN_CTRL_REG_1_RESET	0x8000	/* Soft reset */
 
+#define MII_VCT7_PAIR_0_DISTANCE	0x10
+#define MII_VCT7_PAIR_1_DISTANCE	0x11
+#define MII_VCT7_PAIR_2_DISTANCE	0x12
+#define MII_VCT7_PAIR_3_DISTANCE	0x13
+
+#define MII_VCT7_RESULTS	0x14
+#define MII_VCT7_RESULTS_PAIR3_MASK	0xf000
+#define MII_VCT7_RESULTS_PAIR2_MASK	0x0f00
+#define MII_VCT7_RESULTS_PAIR1_MASK	0x00f0
+#define MII_VCT7_RESULTS_PAIR0_MASK	0x000f
+#define MII_VCT7_RESULTS_PAIR3_SHIFT	12
+#define MII_VCT7_RESULTS_PAIR2_SHIFT	8
+#define MII_VCT7_RESULTS_PAIR1_SHIFT	4
+#define MII_VCT7_RESULTS_PAIR0_SHIFT	0
+#define MII_VCT7_RESULTS_INVALID	0
+#define MII_VCT7_RESULTS_OK		1
+#define MII_VCT7_RESULTS_OPEN		2
+#define MII_VCT7_RESULTS_SAME_SHORT	3
+#define MII_VCT7_RESULTS_CROSS_SHORT	4
+#define MII_VCT7_RESULTS_BUSY		9
+
+#define MII_VCT7_CTRL		0x15
+#define MII_VCT7_CTRL_RUN_NOW			BIT(15)
+#define MII_VCT7_CTRL_RUN_ANEG			BIT(14)
+#define MII_VCT7_CTRL_DISABLE_CROSS		BIT(13)
+#define MII_VCT7_CTRL_RUN_AFTER_BREAK_LINK	BIT(12)
+#define MII_VCT7_CTRL_IN_PROGRESS		BIT(11)
+#define MII_VCT7_CTRL_METERS			BIT(10)
+#define MII_VCT7_CTRL_CENTIMETERS		0
+
 #define LPA_FIBER_1000HALF	0x40
 #define LPA_FIBER_1000FULL	0x20
 
@@ -1635,6 +1667,160 @@ static void marvell_get_stats(struct phy_device *phydev,
 		data[i] = marvell_get_stat(phydev, i);
 }
 
+static int marvell_vct7_cable_test_start(struct phy_device *phydev)
+{
+	int bmcr, bmsr, ret;
+
+	/* If auto-negotiation is enabled, but not complete, the
+	   cable test never completes. So disable auto-neg.
+	*/
+
+	bmcr = phy_read(phydev, MII_BMCR);
+	if (bmcr < 0)
+		return bmcr;
+
+	bmsr = phy_read(phydev, MII_BMCR);
+
+	if (bmsr < 0)
+		return bmsr;
+
+	if ((bmcr & BMCR_ANENABLE) && !(bmsr & BMSR_ANEGCOMPLETE)) {
+		ret =  phy_modify(phydev, MII_BMCR, BMCR_ANENABLE, 0);
+		if (ret < 0)
+			return ret;
+		ret = genphy_soft_reset(phydev);
+		if (ret < 0)
+			return ret;
+	}
+
+	return phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE,
+			       MII_VCT7_CTRL,
+			       MII_VCT7_CTRL_RUN_NOW |
+			       MII_VCT7_CTRL_CENTIMETERS);
+}
+
+static int marvell_vct7_distance_to_length(int distance, bool meter)
+{
+	if (meter)
+		distance *= 100;
+
+	return distance;
+}
+
+static bool marvell_vct7_distance_valid(int result)
+{
+	switch (result) {
+	case MII_VCT7_RESULTS_OPEN:
+	case MII_VCT7_RESULTS_SAME_SHORT:
+	case MII_VCT7_RESULTS_CROSS_SHORT:
+		return true;
+	}
+	return false;
+}
+
+static int marvell_vct7_report_length(struct phy_device *phydev,
+				      int pair, bool meter)
+{
+	int length;
+	int ret;
+
+	ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE,
+			     MII_VCT7_PAIR_0_DISTANCE + pair);
+	if (ret < 0)
+		return ret;
+
+	length = marvell_vct7_distance_to_length(ret, meter);
+
+	phy_cable_test_fault_length(phydev, pair, length);
+
+	return 0;
+}
+
+static int mavell_vct7_cable_test_report_trans(int result)
+{
+	switch (result) {
+	case MII_VCT7_RESULTS_OK:
+		return ETHTOOL_A_CABLE_RESULT_CODE_OK;
+	case MII_VCT7_RESULTS_OPEN:
+		return ETHTOOL_A_CABLE_RESULT_CODE_OPEN;
+	case MII_VCT7_RESULTS_SAME_SHORT:
+		return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT;
+	case MII_VCT7_RESULTS_CROSS_SHORT:
+		return ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT;
+	default:
+		return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC;
+	}
+}
+
+static int marvell_vct7_cable_test_report(struct phy_device *phydev)
+{
+	int pair0, pair1, pair2, pair3;
+	bool meter;
+	int ret;
+
+	ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE,
+			     MII_VCT7_RESULTS);
+	if (ret < 0)
+		return ret;
+
+	pair3 = (ret & MII_VCT7_RESULTS_PAIR3_MASK) >>
+		MII_VCT7_RESULTS_PAIR3_SHIFT;
+	pair2 = (ret & MII_VCT7_RESULTS_PAIR2_MASK) >>
+		MII_VCT7_RESULTS_PAIR2_SHIFT;
+	pair1 = (ret & MII_VCT7_RESULTS_PAIR1_MASK) >>
+		MII_VCT7_RESULTS_PAIR1_SHIFT;
+	pair0 = (ret & MII_VCT7_RESULTS_PAIR0_MASK) >>
+		MII_VCT7_RESULTS_PAIR0_SHIFT;
+
+	phy_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_0,
+			      mavell_vct7_cable_test_report_trans(pair0));
+	phy_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_1,
+			      mavell_vct7_cable_test_report_trans(pair1));
+	phy_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_2,
+			      mavell_vct7_cable_test_report_trans(pair2));
+	phy_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_3,
+			      mavell_vct7_cable_test_report_trans(pair3));
+
+	ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE, MII_VCT7_CTRL);
+	if (ret < 0)
+		return ret;
+
+	meter = ret & MII_VCT7_CTRL_METERS;
+
+	if (marvell_vct7_distance_valid(pair0))
+		marvell_vct7_report_length(phydev, 0, meter);
+	if (marvell_vct7_distance_valid(pair1))
+		marvell_vct7_report_length(phydev, 1, meter);
+	if (marvell_vct7_distance_valid(pair2))
+		marvell_vct7_report_length(phydev, 2, meter);
+	if (marvell_vct7_distance_valid(pair3))
+		marvell_vct7_report_length(phydev, 3, meter);
+
+	return 0;
+}
+
+static int marvell_vct7_cable_test_get_status(struct phy_device *phydev,
+					      bool *finished)
+{
+	int ret;
+
+	*finished = false;
+
+	ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE,
+			     MII_VCT7_CTRL);
+
+	if (ret < 0)
+		return ret;
+
+	if (!(ret & MII_VCT7_CTRL_IN_PROGRESS)) {
+		*finished = true;
+
+		return marvell_vct7_cable_test_report(phydev);
+	}
+
+	return 0;
+}
+
 #ifdef CONFIG_HWMON
 static int m88e1121_get_temp(struct phy_device *phydev, long *temp)
 {
@@ -2320,6 +2506,7 @@ static struct phy_driver marvell_drivers[] = {
 		.phy_id_mask = MARVELL_PHY_ID_MASK,
 		.name = "Marvell 88E1510",
 		.features = PHY_GBIT_FIBRE_FEATURES,
+		.flags = PHY_POLL_CABLE_TEST,
 		.probe = &m88e1510_probe,
 		.config_init = &m88e1510_config_init,
 		.config_aneg = &m88e1510_config_aneg,
@@ -2337,12 +2524,15 @@ static struct phy_driver marvell_drivers[] = {
 		.get_strings = marvell_get_strings,
 		.get_stats = marvell_get_stats,
 		.set_loopback = genphy_loopback,
+		.cable_test_start = marvell_vct7_cable_test_start,
+		.cable_test_get_status = marvell_vct7_cable_test_get_status,
 	},
 	{
 		.phy_id = MARVELL_PHY_ID_88E1540,
 		.phy_id_mask = MARVELL_PHY_ID_MASK,
 		.name = "Marvell 88E1540",
 		/* PHY_GBIT_FEATURES */
+		.flags = PHY_POLL_CABLE_TEST,
 		.probe = m88e1510_probe,
 		.config_init = &marvell_config_init,
 		.config_aneg = &m88e1510_config_aneg,
@@ -2359,6 +2549,8 @@ static struct phy_driver marvell_drivers[] = {
 		.get_stats = marvell_get_stats,
 		.get_tunable = m88e1540_get_tunable,
 		.set_tunable = m88e1540_set_tunable,
+		.cable_test_start = marvell_vct7_cable_test_start,
+		.cable_test_get_status = marvell_vct7_cable_test_get_status,
 	},
 	{
 		.phy_id = MARVELL_PHY_ID_88E1545,
@@ -2366,6 +2558,7 @@ static struct phy_driver marvell_drivers[] = {
 		.name = "Marvell 88E1545",
 		.probe = m88e1510_probe,
 		/* PHY_GBIT_FEATURES */
+		.flags = PHY_POLL_CABLE_TEST,
 		.config_init = &marvell_config_init,
 		.config_aneg = &m88e1510_config_aneg,
 		.read_status = &marvell_read_status,
@@ -2379,6 +2572,8 @@ static struct phy_driver marvell_drivers[] = {
 		.get_sset_count = marvell_get_sset_count,
 		.get_strings = marvell_get_strings,
 		.get_stats = marvell_get_stats,
+		.cable_test_start = marvell_vct7_cable_test_start,
+		.cable_test_get_status = marvell_vct7_cable_test_get_status,
 	},
 	{
 		.phy_id = MARVELL_PHY_ID_88E3016,
@@ -2405,6 +2600,7 @@ static struct phy_driver marvell_drivers[] = {
 		.phy_id_mask = MARVELL_PHY_ID_MASK,
 		.name = "Marvell 88E6390",
 		/* PHY_GBIT_FEATURES */
+		.flags = PHY_POLL_CABLE_TEST,
 		.probe = m88e6390_probe,
 		.config_init = &marvell_config_init,
 		.config_aneg = &m88e6390_config_aneg,
@@ -2421,6 +2617,8 @@ static struct phy_driver marvell_drivers[] = {
 		.get_stats = marvell_get_stats,
 		.get_tunable = m88e1540_get_tunable,
 		.set_tunable = m88e1540_set_tunable,
+		.cable_test_start = marvell_vct7_cable_test_start,
+		.cable_test_get_status = marvell_vct7_cable_test_get_status,
 	},
 };
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 10/13] net: phy: Allow options to be passed to the cable test
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (8 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 09/13] net: phy: marvell: Add cable test support Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 11/13] net: phy: Add helpers and attributes for amplitude graph Andrew Lunn
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

Some PHYs can do more than just measure the distance to a fault.  But
these additional actions are expensive. So allow options to be passed
to enable these additional actions.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/marvell.c            |  6 +++++-
 drivers/net/phy/phy.c                |  5 +++--
 include/linux/phy.h                  |  7 ++++---
 include/uapi/linux/ethtool_netlink.h |  1 +
 net/ethtool/actions.c                | 10 ++++++++--
 5 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 96354513daba..11a19c354533 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1667,10 +1667,14 @@ static void marvell_get_stats(struct phy_device *phydev,
 		data[i] = marvell_get_stat(phydev, i);
 }
 
-static int marvell_vct7_cable_test_start(struct phy_device *phydev)
+static int marvell_vct7_cable_test_start(struct phy_device *phydev,
+					 int options)
 {
 	int bmcr, bmsr, ret;
 
+	if (options)
+		return -EOPNOTSUPP;
+
 	/* If auto-negotiation is enabled, but not complete, the
 	   cable test never completes. So disable auto-neg.
 	*/
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 6540523d773a..38a766fc0923 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -533,7 +533,8 @@ int phy_cable_test_fault_length(struct phy_device *phydev, u8 pair, u16 cm)
 EXPORT_SYMBOL_GPL(phy_cable_test_fault_length);
 
 int phy_start_cable_test(struct phy_device *phydev,
-			 struct netlink_ext_ack *extack, u32 seq)
+			 struct netlink_ext_ack *extack, u32 seq,
+			 int options)
 {
 	int err = -ENOMEM;
 	int ret;
@@ -577,7 +578,7 @@ int phy_start_cable_test(struct phy_device *phydev,
 	/* Mark the carrier down until the test is complete */
 	phy_link_down(phydev, true);
 
-	err = phydev->drv->cable_test_start(phydev);
+	err = phydev->drv->cable_test_start(phydev, options);
 	if (err) {
 		phy_link_up(phydev);
 		goto out_free;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 23c18583ea07..2ef7dc37ea44 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -641,7 +641,7 @@ struct phy_driver {
 			     struct ethtool_eeprom *ee, u8 *data);
 
 	/* Start a cable test */
-	int (*cable_test_start)(struct phy_device *dev);
+	int (*cable_test_start)(struct phy_device *dev, int options);
 	/* Once per second, or on interrupt, request the status of the
 	 * test.
 	 */
@@ -1078,12 +1078,12 @@ int phy_reset_after_clk_enable(struct phy_device *phydev);
 #if IS_ENABLED(CONFIG_PHYLIB)
 int phy_start_cable_test(struct phy_device *phydev,
 			 struct netlink_ext_ack *extack,
-			 u32 seq);
+			 u32 seq, int options);
 #else
 static inline
 int phy_start_cable_test(struct phy_device *phydev,
 			 struct netlink_ext_ack *extack,
-			 u32 seq)
+			 u32 seq, int options)
 {
 	NL_SET_ERR_MSG(extack, "Kernel not compiled with PHYLIB support");
 	return -EOPNOTSUPP;
@@ -1093,6 +1093,7 @@ int phy_start_cable_test(struct phy_device *phydev,
 int phy_cable_test_result(struct phy_device *phydev, u8 pair, u16 result);
 int phy_cable_test_fault_length(struct phy_device *phydev, u8 pair,
 				u16 cm);
+#define PHY_CABLE_TEST_AMPLITUDE_GRAPH BIT(0)
 
 static inline void phy_device_reset(struct phy_device *phydev, int value)
 {
diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h
index aac76a26f97b..841f23ca2306 100644
--- a/include/uapi/linux/ethtool_netlink.h
+++ b/include/uapi/linux/ethtool_netlink.h
@@ -565,6 +565,7 @@ enum {
 enum {
 	ETHTOOL_A_CABLE_TEST_UNSPEC,
 	ETHTOOL_A_CABLE_TEST_DEV,		/* nest - ETHTOOL_A_DEV_* */
+	ETHTOOL_A_CABLE_TEST_AMPLITUDE_GRAPH,
 
 	__ETHTOOL_A_CABLE_TEST_CNT,
 	ETHTOOL_A_CABLE_TEST_MAX = (__ETHTOOL_A_CABLE_TEST_CNT - 1)
diff --git a/net/ethtool/actions.c b/net/ethtool/actions.c
index 8595cc27d532..12ff93c526f0 100644
--- a/net/ethtool/actions.c
+++ b/net/ethtool/actions.c
@@ -382,7 +382,8 @@ int ethnl_act_reset(struct sk_buff *skb, struct genl_info *info)
 static const struct
 nla_policy cable_test_policy[ETHTOOL_A_CABLE_TEST_MAX + 1] = {
 	[ETHTOOL_A_CABLE_TEST_UNSPEC]	= { .type = NLA_REJECT },
-	[ETHTOOL_A_CABLE_TEST_DEV]		= { .type = NLA_NESTED },
+	[ETHTOOL_A_CABLE_TEST_DEV]	= { .type = NLA_NESTED },
+	[ETHTOOL_A_CABLE_TEST_AMPLITUDE_GRAPH] = { .type = NLA_FLAG },
 };
 
 void ethnl_cable_test_notify(struct net_device *dev,
@@ -418,6 +419,7 @@ void ethnl_cable_test_notify(struct net_device *dev,
 int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info)
 {
 	struct nlattr *tb[ETHTOOL_A_CABLE_TEST_MAX + 1];
+	int options = 0;
 	struct net_device *dev;
 	int ret;
 
@@ -435,12 +437,16 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info)
 	if (!dev->phydev)
 		goto out_dev;
 
+	if (tb[ETHTOOL_A_CABLE_TEST_AMPLITUDE_GRAPH])
+		options = PHY_CABLE_TEST_AMPLITUDE_GRAPH;
+
 	rtnl_lock();
 	ret = ethnl_before_ops(dev);
 	if (ret < 0)
 		goto out_rtnl;
 
-	ret = phy_start_cable_test(dev->phydev, info->extack, info->snd_seq);
+	ret = phy_start_cable_test(dev->phydev, info->extack, info->snd_seq,
+				   options);
 
 	ethnl_after_ops(dev);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 11/13] net: phy: Add helpers and attributes for amplitude graph
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (9 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 10/13] net: phy: Allow options to be passed to the cable test Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 12/13] net: phy: marvell: Add support " Andrew Lunn
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

The amplitude graph needs to return the measured amplitude of the
reflected signal for each pair. Add a helper to store such a
measurement into the results skbuf. The size of the transmitted pulse
affects the size of the measured pulse. So add a helper to report the
pulse size.

For a 100m cable, and measurements at one meter interval, the default
size netlink skbuf is too small. Change to 8K.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/phy.c                | 51 +++++++++++++++++++++++++++-
 include/linux/phy.h                  |  4 +++
 include/uapi/linux/ethtool_netlink.h | 20 +++++++++++
 3 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 38a766fc0923..9a210927aec0 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -532,6 +532,55 @@ int phy_cable_test_fault_length(struct phy_device *phydev, u8 pair, u16 cm)
 }
 EXPORT_SYMBOL_GPL(phy_cable_test_fault_length);
 
+int phy_cable_test_amplitude(struct phy_device *phydev,
+			     int distance, u8 pair, int mV)
+{
+	struct nlattr *nest;
+	int ret = -EMSGSIZE;
+
+	nest = ethnl_nest_start(phydev->skb,
+				ETHTOOL_A_CABLE_TEST_EVENT_AMPLITUDE);
+	if (!nest)
+		return -EMSGSIZE;
+
+	if (nla_put_u16(phydev->skb, ETHTOOL_A_CABLE_AMPLITUDE_DISTANCE,
+			distance))
+		goto err;
+	if (nla_put_u8(phydev->skb, ETHTOOL_A_CABLE_AMPLITUDE_PAIR, pair))
+		goto err;
+	if (nla_put_u16(phydev->skb, ETHTOOL_A_CABLE_AMPLITUDE_mV, mV))
+		goto err;
+
+	nla_nest_end(phydev->skb, nest);
+	return 0;
+
+err:
+	nla_nest_cancel(phydev->skb, nest);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phy_cable_test_amplitude);
+
+int phy_cable_test_pulse(struct phy_device *phydev, int mV)
+{
+	struct nlattr *nest;
+	int ret = -EMSGSIZE;
+
+	nest = ethnl_nest_start(phydev->skb, ETHTOOL_A_CABLE_TEST_EVENT_PULSE);
+	if (!nest)
+		return -EMSGSIZE;
+
+	if (nla_put_u16(phydev->skb, ETHTOOL_A_CABLE_PULSE_mV, mV))
+		goto err;
+
+	nla_nest_end(phydev->skb, nest);
+	return 0;
+
+err:
+	nla_nest_cancel(phydev->skb, nest);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phy_cable_test_pulse);
+
 int phy_start_cable_test(struct phy_device *phydev,
 			 struct netlink_ext_ack *extack, u32 seq,
 			 int options)
@@ -556,7 +605,7 @@ int phy_start_cable_test(struct phy_device *phydev,
 		goto out;
 	}
 
-	phydev->skb = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	phydev->skb = genlmsg_new(8192, GFP_KERNEL);
 	if (!phydev->skb)
 		goto out;
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 2ef7dc37ea44..3c5f0c7b8847 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1093,6 +1093,10 @@ int phy_start_cable_test(struct phy_device *phydev,
 int phy_cable_test_result(struct phy_device *phydev, u8 pair, u16 result);
 int phy_cable_test_fault_length(struct phy_device *phydev, u8 pair,
 				u16 cm);
+int phy_cable_test_amplitude(struct phy_device *phydev, int distance, u8 pair,
+			     int mV);
+int phy_cable_test_pulse(struct phy_device *phydev, int mV);
+
 #define PHY_CABLE_TEST_AMPLITUDE_GRAPH BIT(0)
 
 static inline void phy_device_reset(struct phy_device *phydev, int value)
diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h
index 841f23ca2306..613638a423cd 100644
--- a/include/uapi/linux/ethtool_netlink.h
+++ b/include/uapi/linux/ethtool_netlink.h
@@ -550,11 +550,31 @@ enum {
 	ETHTOOL_A_CABLE_LENGTH_MAX = (__ETHTOOL_A_CABLE_LENGTH_CNT - 1)
 };
 
+enum {
+	ETHTOOL_A_CABLE_AMPLITUDE_UNSPEC,
+	ETHTOOL_A_CABLE_AMPLITUDE_DISTANCE,	/* u16 */
+	ETHTOOL_A_CABLE_AMPLITUDE_PAIR,		/* u8 */
+	ETHTOOL_A_CABLE_AMPLITUDE_mV,		/* s16 */
+
+	__ETHTOOL_A_CABLE_AMPLITUDE_CNT,
+	ETHTOOL_A_CABLE_AMPLITUDE_MAX = (__ETHTOOL_A_CABLE_AMPLITUDE_CNT - 1)
+};
+
+enum {
+	ETHTOOL_A_CABLE_PULSE_UNSPEC,
+	ETHTOOL_A_CABLE_PULSE_mV,		/* s16 */
+
+	__ETHTOOL_A_CABLE_PULSE_CNT,
+	ETHTOOL_A_CABLE_PULSE_MAX = (__ETHTOOL_A_CABLE_PULSE_CNT - 1)
+};
+
 enum {
 	ETHTOOL_A_CABLE_TEST_EVENT_UNSPEC,
 	ETHTOOL_A_CABLE_TEST_EVENT_DEV,		/* nest - ETHTOOL_A_DEV_* */
 	ETHTOOL_A_CABLE_TEST_EVENT_RESULT,	/* nest - ETHTOOL_A_CABLE_RESULT_ */
 	ETHTOOL_A_CABLE_TEST_EVENT_FAULT_LENGTH,/* nest - ETHTOOL_A_CABLE_FAULT_LENGTH_ */
+	ETHTOOL_A_CABLE_TEST_EVENT_AMPLITUDE,	/* next - ETHTOOL_A_CABLE_AMPLITUDE_ */
+	ETHTOOL_A_CABLE_TEST_EVENT_PULSE,	/* next - ETHTOOL_A_CABLE_PULSE_ */
 
 	__ETHTOOL_A_CABLE_TEST_EVENT_CNT,
 	ETHTOOL_A_CABLE_TEST_EVENT_MAX = (__ETHTOOL_A_CABLE_TEST_EVENT_CNT - 1)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 12/13] net: phy: marvell: Add support for amplitude graph
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (10 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 11/13] net: phy: Add helpers and attributes for amplitude graph Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-12 16:05 ` [PATCH RFC 13/13] net: phy: Put interface into oper testing during cable test Andrew Lunn
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

The Marvell PHYs can measure the amplitude of the returned signal for
a given distance. Implement this option of the cable test
infrastructure.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/marvell.c | 178 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 175 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 11a19c354533..5f200ad51326 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -42,6 +42,7 @@
 #define MII_MARVELL_FIBER_PAGE		0x01
 #define MII_MARVELL_MSCR_PAGE		0x02
 #define MII_MARVELL_LED_PAGE		0x03
+#define MII_MARVELL_VCT5_PAGE		0x05
 #define MII_MARVELL_MISC_TEST_PAGE	0x06
 #define MII_MARVELL_VCT7_PAGE		0x07
 #define MII_MARVELL_WOL_PAGE		0x11
@@ -158,6 +159,46 @@
 #define MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII	0x1	/* SGMII to copper */
 #define MII_88E1510_GEN_CTRL_REG_1_RESET	0x8000	/* Soft reset */
 
+#define MII_VCT5_TX_RX_MDI0_COUPLING	0x10
+#define MII_VCT5_TX_RX_MDI1_COUPLING	0x11
+#define MII_VCT5_TX_RX_MDI2_COUPLING	0x12
+#define MII_VCT5_TX_RX_MDI3_COUPLING	0x13
+#define MII_VCT5_TX_RX_AMPLITUDE_MASK	0x7f00
+#define MII_VCT5_TX_RX_AMPLITUDE_SHIFT	8
+#define MII_VCT5_TX_RX_COUPLING_POSITIVE_REFLECTION	BIT(15)
+
+#define MII_VCT5_CTRL				0x17
+#define MII_VCT5_CTRL_ENABLE				BIT(15)
+#define MII_VCT5_CTRL_COMPLETE				BIT(14)
+#define MII_VCT5_CTRL_SAME_CHANNEL			(0 << 11)
+#define MII_VCT5_CTRL_TX0_CHANNEL			(1 << 11)
+#define MII_VCT5_CTRL_TX1_CHANNEL			(2 << 11)
+#define MII_VCT5_CTRL_TX2_CHANNEL			(3 << 11)
+#define MII_VCT5_CTRL_TX3_CHANNEL			(4 << 11)
+#define MII_VCT5_CTRL_SAMPLES_2				(0 << 8)
+#define MII_VCT5_CTRL_SAMPLES_4				(1 << 8)
+#define MII_VCT5_CTRL_SAMPLES_8				(2 << 8)
+#define MII_VCT5_CTRL_SAMPLES_16			(3 << 8)
+#define MII_VCT5_CTRL_SAMPLES_32			(4 << 8)
+#define MII_VCT5_CTRL_SAMPLES_64			(5 << 8)
+#define MII_VCT5_CTRL_SAMPLES_126			(5 << 8)
+#define MII_VCT5_CTRL_SAMPLES_DEFAULT			(6 << 8)
+#define MII_VCT5_CTRL_MODE_MAXIMUM_PEEK			(0 << 6)
+#define MII_VCT5_CTRL_MODE_FIRST_LAST_PEEK		(1 << 6)
+#define MII_VCT5_CTRL_MODE_OFFSET			(2 << 6)
+#define MII_VCT5_CTRL_SAMPLE_POINT			(3 << 6)
+#define MII_VCT5_CTRL_PEEK_HYST_DEFAULT			3
+
+#define MII_VCT5_SAMPLE_POINT_DISTANCE		0x18
+#define MII_VCT5_TX_PULSE_CTRL			0x1c
+#define MII_VCT5_TX_PULSE_CTRL_DONT_WAIT_LINK_DOWN	BIT(12)
+#define MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_128nS	(0 << 10)
+#define MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_96nS		(1 << 10)
+#define MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_64nS		(2 << 10)
+#define MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS		(3 << 10)
+#define MII_VCT5_TX_PULSE_CTRL_MAX_AMP			BIT(7)
+#define MII_VCT5_TX_PULSE_CTRL_GT_140m_46_86mV		(6 << 0)
+
 #define MII_VCT7_PAIR_0_DISTANCE	0x10
 #define MII_VCT7_PAIR_1_DISTANCE	0x11
 #define MII_VCT7_PAIR_2_DISTANCE	0x12
@@ -224,6 +265,7 @@ struct marvell_priv {
 	u64 stats[ARRAY_SIZE(marvell_hw_stats)];
 	char *hwmon_name;
 	struct device *hwmon_dev;
+	int cable_test_options;
 };
 
 static int marvell_read_page(struct phy_device *phydev)
@@ -1667,14 +1709,131 @@ static void marvell_get_stats(struct phy_device *phydev,
 		data[i] = marvell_get_stat(phydev, i);
 }
 
+static int marvell_vct5_wait_complete(struct phy_device *phydev)
+{
+	int i;
+	u16 val;
+
+	for (i = 0; i < 32; i++) {
+		val = phy_read_paged(phydev, MII_MARVELL_VCT5_PAGE,
+				     MII_VCT5_CTRL);
+		if (val < 0)
+			return val;
+
+		if (val & MII_VCT5_CTRL_COMPLETE)
+			return 0;
+
+		usleep_range(1000, 2000);
+	}
+
+	phydev_err(phydev, "Timeout while waiting for cable test to finish\n");
+	return -ETIMEDOUT;
+}
+
+static int marvell_vct5_amplitude(struct phy_device *phydev, int pair)
+{
+	int amplitude;
+	int val;
+	int reg;
+
+	reg = MII_VCT5_TX_RX_MDI0_COUPLING + pair;
+	val = phy_read_paged(phydev, MII_MARVELL_VCT5_PAGE, reg);
+
+	if (val < 0)
+		return 0;
+
+	amplitude = (val & MII_VCT5_TX_RX_AMPLITUDE_MASK) >>
+		MII_VCT5_TX_RX_AMPLITUDE_SHIFT;
+
+	if (!(val & MII_VCT5_TX_RX_COUPLING_POSITIVE_REFLECTION))
+		amplitude = -amplitude;
+
+	return 1000 * amplitude / 128;
+}
+
+static int marvell_vct5_amplitude_distance(struct phy_device *phydev,
+					   int distance)
+{
+	int mV_pair0, mV_pair1, mV_pair2, mV_pair3;
+	u16 reg;
+	int err;
+
+	err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE,
+			      MII_VCT5_SAMPLE_POINT_DISTANCE,
+			      distance);
+	if (err)
+		return err;
+
+	reg = MII_VCT5_CTRL_ENABLE |
+		MII_VCT5_CTRL_SAME_CHANNEL |
+		MII_VCT5_CTRL_SAMPLES_DEFAULT |
+		MII_VCT5_CTRL_SAMPLE_POINT |
+		MII_VCT5_CTRL_PEEK_HYST_DEFAULT;
+	err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE,
+			      MII_VCT5_CTRL, reg);
+	if (err)
+		return err;
+
+	err = marvell_vct5_wait_complete(phydev);
+	if (err)
+		return err;
+
+	mV_pair0 = marvell_vct5_amplitude(phydev, 0);
+	mV_pair1 = marvell_vct5_amplitude(phydev, 1);
+	mV_pair2 = marvell_vct5_amplitude(phydev, 2);
+	mV_pair3 = marvell_vct5_amplitude(phydev, 3);
+
+	phy_cable_test_amplitude(phydev, distance, ETHTOOL_A_CABLE_PAIR_0,
+				 mV_pair0);
+	phy_cable_test_amplitude(phydev, distance, ETHTOOL_A_CABLE_PAIR_1,
+				 mV_pair1);
+	phy_cable_test_amplitude(phydev, distance, ETHTOOL_A_CABLE_PAIR_2,
+				 mV_pair2);
+	phy_cable_test_amplitude(phydev, distance, ETHTOOL_A_CABLE_PAIR_3,
+				 mV_pair3);
+
+	return 0;
+}
+
+static int marvell_vct5_amplitude_graph(struct phy_device *phydev)
+{
+	int distance;
+	int err;
+	u16 reg;
+
+	/* Disable  VCT7 */
+	err = phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE,
+			      MII_VCT7_CTRL, 0);
+
+	/* Allow the cable time to become idle */
+	msleep(1500);
+
+	reg = MII_VCT5_TX_PULSE_CTRL_GT_140m_46_86mV |
+		MII_VCT5_TX_PULSE_CTRL_DONT_WAIT_LINK_DOWN |
+		MII_VCT5_TX_PULSE_CTRL_MAX_AMP |
+		MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS;
+
+	err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE,
+			      MII_VCT5_TX_PULSE_CTRL, reg);
+	if (err)
+		return err;
+
+	for (distance = 0; distance <= 100; distance++) {
+		err = marvell_vct5_amplitude_distance(phydev, distance);
+		if (err)
+			return err;
+	}
+
+	/* 1000 mV pulse is used */
+	return phy_cable_test_pulse(phydev, 1000);
+}
+
 static int marvell_vct7_cable_test_start(struct phy_device *phydev,
 					 int options)
 {
+	struct marvell_priv *priv = phydev->priv;
 	int bmcr, bmsr, ret;
 
-	if (options)
-		return -EOPNOTSUPP;
-
 	/* If auto-negotiation is enabled, but not complete, the
 	   cable test never completes. So disable auto-neg.
 	*/
@@ -1697,6 +1856,12 @@ static int marvell_vct7_cable_test_start(struct phy_device *phydev,
 			return ret;
 	}
 
+	priv->cable_test_options = options;
+
+	if (options & PHY_CABLE_TEST_AMPLITUDE_GRAPH) {
+		return 0;
+	}
+
 	return phy_write_paged(phydev, MII_MARVELL_VCT7_PAGE,
 			       MII_VCT7_CTRL,
 			       MII_VCT7_CTRL_RUN_NOW |
@@ -1806,8 +1971,15 @@ static int marvell_vct7_cable_test_report(struct phy_device *phydev)
 static int marvell_vct7_cable_test_get_status(struct phy_device *phydev,
 					      bool *finished)
 {
+	struct marvell_priv *priv = phydev->priv;
 	int ret;
 
+	if (priv->cable_test_options & PHY_CABLE_TEST_AMPLITUDE_GRAPH) {
+		ret = marvell_vct5_amplitude_graph(phydev);
+		*finished = true;
+		return ret;
+	}
+
 	*finished = false;
 
 	ret = phy_read_paged(phydev, MII_MARVELL_VCT7_PAGE,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH RFC 13/13] net: phy: Put interface into oper testing during cable test
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (11 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 12/13] net: phy: marvell: Add support " Andrew Lunn
@ 2019-06-12 16:05 ` Andrew Lunn
  2019-06-13  9:58 ` [PATCH RFC 00/13] Ethernet PHY cable test support Raju Lakkaraju
  2019-06-13 11:31 ` Raju Lakkaraju
  14 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-12 16:05 UTC (permalink / raw)
  To: netdev; +Cc: Florian Fainelli, Heiner Kallweit, Raju.Lakkaraju, Andrew Lunn

Since running a cable test is disruptive, put the interface into
operative state testing while the test is running.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/phy.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 9a210927aec0..f3fa73974af3 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -585,6 +585,7 @@ int phy_start_cable_test(struct phy_device *phydev,
 			 struct netlink_ext_ack *extack, u32 seq,
 			 int options)
 {
+	struct net_device *dev = phydev->attached_dev;
 	int err = -ENOMEM;
 	int ret;
 
@@ -627,8 +628,10 @@ int phy_start_cable_test(struct phy_device *phydev,
 	/* Mark the carrier down until the test is complete */
 	phy_link_down(phydev, true);
 
+	netif_testing_on(dev);
 	err = phydev->drv->cable_test_start(phydev, options);
 	if (err) {
+		netif_testing_off(dev);
 		phy_link_up(phydev);
 		goto out_free;
 	}
@@ -988,6 +991,8 @@ EXPORT_SYMBOL(phy_request_interrupt);
  */
 void phy_stop(struct phy_device *phydev)
 {
+	struct net_device *dev = phydev->attached_dev;
+
 	if (!phy_is_started(phydev)) {
 		WARN(1, "called from state %s\n",
 		     phy_state_to_str(phydev->state));
@@ -996,8 +1001,10 @@ void phy_stop(struct phy_device *phydev)
 
 	mutex_lock(&phydev->lock);
 
-	if (phydev->state == PHY_CABLETEST)
+	if (phydev->state == PHY_CABLETEST) {
 		phy_cable_test_abort(phydev);
+		netif_testing_off(dev);
+	};
 
 	if (phy_interrupt_is_valid(phydev))
 		phy_disable_interrupts(phydev);
@@ -1068,6 +1075,7 @@ void phy_state_machine(struct work_struct *work)
 	struct delayed_work *dwork = to_delayed_work(work);
 	struct phy_device *phydev =
 			container_of(dwork, struct phy_device, state_queue);
+	struct net_device *dev = phydev->attached_dev;
 	bool needs_aneg = false, do_suspend = false;
 	enum phy_state old_state;
 	bool finished = false;
@@ -1108,6 +1116,7 @@ void phy_state_machine(struct work_struct *work)
 		err = phydev->drv->cable_test_get_status(phydev, &finished);
 		if (err) {
 			phy_cable_test_abort(phydev);
+			netif_testing_off(dev);
 			needs_aneg = true;
 			phydev->state = PHY_UP;
 			break;
@@ -1115,6 +1124,7 @@ void phy_state_machine(struct work_struct *work)
 
 		if (finished) {
 			phy_cable_test_finished(phydev);
+			netif_testing_off(dev);
 			needs_aneg = true;
 			phydev->state = PHY_UP;
 		}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH RFC 09/13] net: phy: marvell: Add cable test support
  2019-06-12 16:05 ` [PATCH RFC 09/13] net: phy: marvell: Add cable test support Andrew Lunn
@ 2019-06-13  3:08   ` Florian Fainelli
  0 siblings, 0 replies; 19+ messages in thread
From: Florian Fainelli @ 2019-06-13  3:08 UTC (permalink / raw)
  To: Andrew Lunn, netdev; +Cc: Heiner Kallweit, Raju.Lakkaraju



On 6/12/2019 9:05 AM, Andrew Lunn wrote:
> The Marvell PHYs have a couple of different register sets for
> performing cable tests. Page 7 provides the simplest to use. However,
> it does not provide cable length, only length to a fault, when there
> is a fault.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
[snip]

> + 	bmcr = phy_read(phydev, MII_BMCR);
> +	if (bmcr < 0)
> +		return bmcr;
> +
> +	bmsr = phy_read(phydev, MII_BMCR);

Should this second read be for MII_BMSR?
-- 
Florian

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH RFC 00/13] Ethernet PHY cable test support
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (12 preceding siblings ...)
  2019-06-12 16:05 ` [PATCH RFC 13/13] net: phy: Put interface into oper testing during cable test Andrew Lunn
@ 2019-06-13  9:58 ` Raju Lakkaraju
  2019-06-13 13:06   ` Andrew Lunn
  2019-06-14  0:01   ` Andrew Lunn
  2019-06-13 11:31 ` Raju Lakkaraju
  14 siblings, 2 replies; 19+ messages in thread
From: Raju Lakkaraju @ 2019-06-13  9:58 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, Florian Fainelli, Heiner Kallweit

Hi Andrew,

Look like these patches are not create from "net-next" branch.
Can you please share branch detail where i can apply patches and check the code
flow?

The 06/12/2019 18:05, Andrew Lunn wrote:
> External E-Mail
> 
> 
> This patchset adds support for executing Ethernet PHY cable tests and
> 2.20.1
> 
> 

---
Thanks,
Raju

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH RFC 00/13] Ethernet PHY cable test support
  2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
                   ` (13 preceding siblings ...)
  2019-06-13  9:58 ` [PATCH RFC 00/13] Ethernet PHY cable test support Raju Lakkaraju
@ 2019-06-13 11:31 ` Raju Lakkaraju
  14 siblings, 0 replies; 19+ messages in thread
From: Raju Lakkaraju @ 2019-06-13 11:31 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, Florian Fainelli, Heiner Kallweit

Hi Andrew,

Finally, I'm able to figureout the branch details (kernel:
ff24e4980a68)and apply your patches.
Give me sometime to review your code and sent my comments.

The 06/12/2019 18:05, Andrew Lunn wrote:
> External E-Mail
> 
> 
> This patchset adds support for executing Ethernet PHY cable tests and
> reporting the results back to user space. The Marvell PHY driver has
> been extended so some of its cable test features can be used.
> 
> -- 
> 2.20.1
> 
---
Thanks,
Raju

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH RFC 00/13] Ethernet PHY cable test support
  2019-06-13  9:58 ` [PATCH RFC 00/13] Ethernet PHY cable test support Raju Lakkaraju
@ 2019-06-13 13:06   ` Andrew Lunn
  2019-06-14  0:01   ` Andrew Lunn
  1 sibling, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-13 13:06 UTC (permalink / raw)
  To: Raju Lakkaraju; +Cc: netdev, Florian Fainelli, Heiner Kallweit

On Thu, Jun 13, 2019 at 03:28:04PM +0530, Raju Lakkaraju wrote:
> Hi Andrew,
> 
> Look like these patches are not create from "net-next" branch.

Correct. As the cover note says, they are dependent on the work by
Michal Kubecek implementing ethtool-nl. He is currently using an older
tree, or at least he was when i forked his code.

> Can you please share branch detail where i can apply patches and check the code
> flow?

Yes, i can push out a branch, later today.

     Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH RFC 00/13] Ethernet PHY cable test support
  2019-06-13  9:58 ` [PATCH RFC 00/13] Ethernet PHY cable test support Raju Lakkaraju
  2019-06-13 13:06   ` Andrew Lunn
@ 2019-06-14  0:01   ` Andrew Lunn
  1 sibling, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2019-06-14  0:01 UTC (permalink / raw)
  To: Raju Lakkaraju; +Cc: netdev, Florian Fainelli, Heiner Kallweit

On Thu, Jun 13, 2019 at 03:28:04PM +0530, Raju Lakkaraju wrote:
> Hi Andrew,
> 
> Look like these patches are not create from "net-next" branch.
> Can you please share branch detail where i can apply patches and check the code
> flow?

Hi Raju

There is a branch https://github.com/lunn/linux.git v5.1-rc7-cable-test-vct7

You can also find the user space code in my github.

    Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2019-06-14  0:01 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 16:05 [PATCH RFC 00/13] Ethernet PHY cable test support Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 01/13] net: phy: Add cable test support to state machine Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 02/13] net: phy: Add support for polling cable test Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 03/13] net: ethtool: netlink: Add support for triggering a " Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 04/13] net: ethtool: Add Properties for cable test reports Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 05/13] net: ethtool: Make helpers public Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 06/13] net: phy: Add infrastructure for reporting cable test results Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 07/13] net: phy: cable test: Use request seq in broadcast reply Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 08/13] net: phy: Add helpers for reporting test results Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 09/13] net: phy: marvell: Add cable test support Andrew Lunn
2019-06-13  3:08   ` Florian Fainelli
2019-06-12 16:05 ` [PATCH RFC 10/13] net: phy: Allow options to be passed to the cable test Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 11/13] net: phy: Add helpers and attributes for amplitude graph Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 12/13] net: phy: marvell: Add support " Andrew Lunn
2019-06-12 16:05 ` [PATCH RFC 13/13] net: phy: Put interface into oper testing during cable test Andrew Lunn
2019-06-13  9:58 ` [PATCH RFC 00/13] Ethernet PHY cable test support Raju Lakkaraju
2019-06-13 13:06   ` Andrew Lunn
2019-06-14  0:01   ` Andrew Lunn
2019-06-13 11:31 ` Raju Lakkaraju

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.