mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jijie Shao <shaojijie@huawei.com>
To: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>
Cc: <shenjian15@huawei.com>, <wangpeiyang1@huawei.com>,
	<liuyonglong@huawei.com>, <chenhao418@huawei.com>,
	<shaojijie@huawei.com>, <sudongming1@huawei.com>,
	<xujunsheng@huawei.com>, <shiyongbang@huawei.com>,
	<libaihan@huawei.com>, <zhuyuan@huawei.com>,
	<forest.zhouchang@huawei.com>, <andrew@lunn.ch>,
	<jdamato@fastly.com>, <horms@kernel.org>,
	<jonathan.cameron@huawei.com>,
	<shameerali.kolothum.thodi@huawei.com>, <salil.mehta@huawei.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH V8 net-next 08/11] net: hibmcge: Implement some ethtool_ops functions
Date: Mon, 9 Sep 2024 10:31:38 +0800	[thread overview]
Message-ID: <20240909023141.3234567-9-shaojijie@huawei.com> (raw)
In-Reply-To: <20240909023141.3234567-1-shaojijie@huawei.com>

Implement the .get_drvinfo .get_link .get_link_ksettings to get
the basic information and working status of the driver.
Implement the .set_link_ksettings to modify the rate, duplex,
and auto-negotiation status.

Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
ChangeLog:
RFC v1 -> RFC v2:
  - Use ethtool_op_get_link(), phy_ethtool_get_link_ksettings(),
    and phy_ethtool_set_link_ksettings() to simplify the code, suggested by Andrew.
  - Delete workqueue for this patch set, suggested by Jonathan.
  RFC v1: https://lore.kernel.org/all/20240731094245.1967834-1-shaojijie@huawei.com/
---
 .../ethernet/hisilicon/hibmcge/hbg_ethtool.c    | 17 +++++++++++++++++
 .../ethernet/hisilicon/hibmcge/hbg_ethtool.h    | 11 +++++++++++
 .../net/ethernet/hisilicon/hibmcge/hbg_main.c   |  2 ++
 3 files changed, 30 insertions(+)
 create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c
 create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.h

diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c
new file mode 100644
index 000000000000..c3370114aef3
--- /dev/null
+++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+// Copyright (c) 2024 Hisilicon Limited.
+
+#include <linux/ethtool.h>
+#include <linux/phy.h>
+#include "hbg_ethtool.h"
+
+static const struct ethtool_ops hbg_ethtool_ops = {
+	.get_link		= ethtool_op_get_link,
+	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
+	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
+};
+
+void hbg_ethtool_set_ops(struct net_device *netdev)
+{
+	netdev->ethtool_ops = &hbg_ethtool_ops;
+}
diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.h b/drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.h
new file mode 100644
index 000000000000..628707ec2686
--- /dev/null
+++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/* Copyright (c) 2024 Hisilicon Limited. */
+
+#ifndef __HBG_ETHTOOL_H
+#define __HBG_ETHTOOL_H
+
+#include <linux/netdevice.h>
+
+void hbg_ethtool_set_ops(struct net_device *netdev);
+
+#endif
diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
index 4fc8b649f034..2865866669be 100644
--- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
+++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
@@ -6,6 +6,7 @@
 #include <linux/netdevice.h>
 #include <linux/pci.h>
 #include "hbg_common.h"
+#include "hbg_ethtool.h"
 #include "hbg_hw.h"
 #include "hbg_irq.h"
 #include "hbg_mdio.h"
@@ -242,6 +243,7 @@ static int hbg_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	netdev->min_mtu = priv->dev_specs.min_mtu;
 	hbg_change_mtu(priv, HBG_DEFAULT_MTU_SIZE);
 	hbg_net_set_mac_address(priv->netdev, &priv->dev_specs.mac_addr);
+	hbg_ethtool_set_ops(netdev);
 	ret = devm_register_netdev(dev, netdev);
 	if (ret)
 		return dev_err_probe(dev, ret, "failed to register netdev\n");
-- 
2.33.0


  parent reply	other threads:[~2024-09-09  2:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-09  2:31 [PATCH V8 net-next 00/11] Add support of HIBMCGE Ethernet Driver Jijie Shao
2024-09-09  2:31 ` [PATCH V8 net-next 01/11] net: hibmcge: Add pci table supported in this module Jijie Shao
2024-09-09  2:31 ` [PATCH V8 net-next 02/11] net: hibmcge: Add read/write registers supported through the bar space Jijie Shao
2024-09-09  2:31 ` [PATCH V8 net-next 03/11] net: hibmcge: Add mdio and hardware configuration supported in this module Jijie Shao
2024-09-09  2:31 ` [PATCH V8 net-next 04/11] net: hibmcge: Add interrupt " Jijie Shao
2024-09-09  2:31 ` [PATCH V8 net-next 05/11] net: hibmcge: Implement some .ndo functions Jijie Shao
2024-09-09  3:05   ` Kalesh Anakkur Purayil
2024-09-09  4:04     ` Jijie Shao
2024-09-09 12:19       ` Andrew Lunn
2024-09-09 14:30         ` Jijie Shao
2024-09-09 14:48           ` Andrew Lunn
2024-09-10  6:26             ` Jijie Shao
2024-09-09  2:31 ` [PATCH V8 net-next 06/11] net: hibmcge: Implement .ndo_start_xmit function Jijie Shao
2024-09-09  2:31 ` [PATCH V8 net-next 07/11] net: hibmcge: Implement rx_poll function to receive packets Jijie Shao
2024-09-09  2:31 ` Jijie Shao [this message]
2024-09-09  2:31 ` [PATCH V8 net-next 09/11] net: hibmcge: Add a Makefile and update Kconfig for hibmcge Jijie Shao
2024-09-09  2:31 ` [PATCH V8 net-next 10/11] net: hibmcge: Add maintainer " Jijie Shao
2024-09-09  2:31 ` [PATCH V8 net-next 11/11] net: add ndo_validate_addr check in dev_set_mac_address Jijie Shao

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=20240909023141.3234567-9-shaojijie@huawei.com \
    --to=shaojijie@huawei.com \
    --cc=andrew@lunn.ch \
    --cc=chenhao418@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=forest.zhouchang@huawei.com \
    --cc=horms@kernel.org \
    --cc=jdamato@fastly.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=kuba@kernel.org \
    --cc=libaihan@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=salil.mehta@huawei.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=shiyongbang@huawei.com \
    --cc=sudongming1@huawei.com \
    --cc=wangpeiyang1@huawei.com \
    --cc=xujunsheng@huawei.com \
    --cc=zhuyuan@huawei.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

all inboxes | Powered by JetHome®