]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
net: ethernet: xilinx: Add support for phy query through ethtool
authorKedareswara rao Appana <appanad@xilinx.com>
Mon, 18 Sep 2017 09:57:49 +0000 (15:27 +0530)
committerMichal Simek <monstr@monstr.eu>
Tue, 3 Oct 2017 15:26:28 +0000 (17:26 +0200)
This patch adds support querying the settings
related to PHY through ethtool.

Signed-off-by: Kedareswara rao Appana <appanad@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/net/ethernet/xilinx/xilinx_axienet_main.c

index 3ada6f8689d79a78cc982c8e3a173b864572b72b..685a826d3533945378fa18602965583c12020fca 100644 (file)
@@ -1737,6 +1737,51 @@ static const struct net_device_ops axienet_netdev_ops = {
 #endif
 };
 
+/**
+ * axienet_ethtools_get_settings - Get Axi Ethernet settings related to PHY.
+ * @ndev:      Pointer to net_device structure
+ * @ecmd:      Pointer to ethtool_cmd structure
+ *
+ * This implements ethtool command for getting PHY settings. If PHY could
+ * not be found, the function returns -ENODEV. This function calls the
+ * relevant PHY ethtool API to get the PHY settings.
+ * Issue "ethtool ethX" under linux prompt to execute this function.
+ *
+ * Return: 0 on success, -ENODEV if PHY doesn't exist
+ */
+static int axienet_ethtools_get_settings(struct net_device *ndev,
+                                        struct ethtool_cmd *ecmd)
+{
+       struct phy_device *phydev = ndev->phydev;
+
+       if (!phydev)
+               return -ENODEV;
+       return phy_ethtool_gset(phydev, ecmd);
+}
+
+/**
+ * axienet_ethtools_set_settings - Set PHY settings as passed in the argument.
+ * @ndev:      Pointer to net_device structure
+ * @ecmd:      Pointer to ethtool_cmd structure
+ *
+ * This implements ethtool command for setting various PHY settings. If PHY
+ * could not be found, the function returns -ENODEV. This function calls the
+ * relevant PHY ethtool API to set the PHY.
+ * Issue e.g. "ethtool -s ethX speed 1000" under linux prompt to execute this
+ * function.
+ *
+ * Return: 0 on success, -ENODEV if PHY doesn't exist
+ */
+static int axienet_ethtools_set_settings(struct net_device *ndev,
+                                        struct ethtool_cmd *ecmd)
+{
+       struct phy_device *phydev = ndev->phydev;
+
+       if (!phydev)
+               return -ENODEV;
+       return phy_ethtool_sset(phydev, ecmd);
+}
+
 /**
  * axienet_ethtools_get_drvinfo - Get various Axi Ethernet driver information.
  * @ndev:      Pointer to net_device structure
@@ -1982,6 +2027,8 @@ static int axienet_ethtools_get_ts_info(struct net_device *ndev,
 #endif
 
 static const struct ethtool_ops axienet_ethtool_ops = {
+       .get_settings   = axienet_ethtools_get_settings,
+       .set_settings   = axienet_ethtools_set_settings,
        .get_drvinfo    = axienet_ethtools_get_drvinfo,
        .get_regs_len   = axienet_ethtools_get_regs_len,
        .get_regs       = axienet_ethtools_get_regs,