[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250213035529.2402283-8-shaojijie@huawei.com>
Date: Thu, 13 Feb 2025 11:55:29 +0800
From: Jijie Shao <shaojijie@...wei.com>
To: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<pabeni@...hat.com>, <andrew+netdev@...n.ch>, <horms@...nel.org>
CC: <shenjian15@...wei.com>, <wangpeiyang1@...wei.com>,
<liuyonglong@...wei.com>, <chenhao418@...wei.com>, <sudongming1@...wei.com>,
<xujunsheng@...wei.com>, <shiyongbang@...wei.com>, <libaihan@...wei.com>,
<jonathan.cameron@...wei.com>, <shameerali.kolothum.thodi@...wei.com>,
<salil.mehta@...wei.com>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <shaojijie@...wei.com>
Subject: [PATCH net-next 7/7] net: hibmcge: Add ioctl supported in this module
This patch implements the ioctl interface to
read and write the PHY register.
Signed-off-by: Jijie Shao <shaojijie@...wei.com>
---
.../net/ethernet/hisilicon/hibmcge/hbg_main.c | 18 ++++++++++++++++++
.../net/ethernet/hisilicon/hibmcge/hbg_mdio.c | 10 ++++++++++
.../net/ethernet/hisilicon/hibmcge/hbg_mdio.h | 2 ++
3 files changed, 30 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
index 78999d41f41d..afd04ed65eee 100644
--- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
+++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
@@ -273,6 +273,23 @@ static netdev_features_t hbg_net_fix_features(struct net_device *netdev,
return features & HBG_SUPPORT_FEATURES;
}
+static int hbg_net_eth_ioctl(struct net_device *dev, struct ifreq *ifr, s32 cmd)
+{
+ struct hbg_priv *priv = netdev_priv(dev);
+
+ if (test_bit(HBG_NIC_STATE_RESETTING, &priv->state))
+ return -EBUSY;
+
+ switch (cmd) {
+ case SIOCGMIIPHY:
+ case SIOCGMIIREG:
+ case SIOCSMIIREG:
+ return hbg_mdio_ioctl(priv, ifr, cmd);
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
static const struct net_device_ops hbg_netdev_ops = {
.ndo_open = hbg_net_open,
.ndo_stop = hbg_net_stop,
@@ -284,6 +301,7 @@ static const struct net_device_ops hbg_netdev_ops = {
.ndo_set_rx_mode = hbg_net_set_rx_mode,
.ndo_get_stats64 = hbg_net_get_stats,
.ndo_fix_features = hbg_net_fix_features,
+ .ndo_eth_ioctl = hbg_net_eth_ioctl,
};
static void hbg_service_task(struct work_struct *work)
diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c
index 8de6d57bd5f3..7080f3011f2d 100644
--- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c
@@ -246,3 +246,13 @@ int hbg_mdio_init(struct hbg_priv *priv)
hbg_mdio_init_hw(priv);
return hbg_phy_connect(priv);
}
+
+int hbg_mdio_ioctl(struct hbg_priv *priv, struct ifreq *ifr, int cmd)
+{
+ struct hbg_mac *mac = &priv->mac;
+
+ if (!mac->phydev)
+ return -ENODEV;
+
+ return phy_mii_ioctl(mac->phydev, ifr, cmd);
+}
diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.h b/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.h
index febd02a309c7..3edca6cd0801 100644
--- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.h
+++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.h
@@ -9,4 +9,6 @@
int hbg_mdio_init(struct hbg_priv *priv);
void hbg_phy_start(struct hbg_priv *priv);
void hbg_phy_stop(struct hbg_priv *priv);
+int hbg_mdio_ioctl(struct hbg_priv *priv, struct ifreq *ifr, int cmd);
+
#endif
--
2.33.0
Powered by blists - more mailing lists