diff mbox series

[net-next,v2] net: wangxun: Add base ethtool ops

Message ID 20230213095959.55773-1-mengyuanlou@net-swift.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] net: wangxun: Add base ethtool ops | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 4 maintainers not CCed: davem@davemloft.net edumazet@google.com pabeni@redhat.com kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? WARNING: line length of 83 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Mengyuan Lou Feb. 13, 2023, 9:59 a.m. UTC
Add base ethtool ops get_drvinfo for ngbe and txgbe.

Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
---
Change log:
v2:
- Remove dot in the patch subject.
- Remove MODULE_LICENSE() in wx_ethtool.c

 drivers/net/ethernet/wangxun/libwx/Makefile   |  2 +-
 .../net/ethernet/wangxun/libwx/wx_ethtool.c   | 27 +++++++++++++++++++
 .../net/ethernet/wangxun/libwx/wx_ethtool.h   |  9 +++++++
 drivers/net/ethernet/wangxun/libwx/wx_type.h  |  1 +
 drivers/net/ethernet/wangxun/ngbe/ngbe_main.c |  5 ++++
 .../net/ethernet/wangxun/txgbe/txgbe_main.c   |  3 +++
 6 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
 create mode 100644 drivers/net/ethernet/wangxun/libwx/wx_ethtool.h

Comments

Leon Romanovsky Feb. 13, 2023, 11:40 a.m. UTC | #1
On Mon, Feb 13, 2023 at 05:59:59PM +0800, Mengyuan Lou wrote:
> Add base ethtool ops get_drvinfo for ngbe and txgbe.
> 
> Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
> ---
> Change log:
> v2:
> - Remove dot in the patch subject.
> - Remove MODULE_LICENSE() in wx_ethtool.c
> 
>  drivers/net/ethernet/wangxun/libwx/Makefile   |  2 +-
>  .../net/ethernet/wangxun/libwx/wx_ethtool.c   | 27 +++++++++++++++++++
>  .../net/ethernet/wangxun/libwx/wx_ethtool.h   |  9 +++++++
>  drivers/net/ethernet/wangxun/libwx/wx_type.h  |  1 +
>  drivers/net/ethernet/wangxun/ngbe/ngbe_main.c |  5 ++++
>  .../net/ethernet/wangxun/txgbe/txgbe_main.c   |  3 +++
>  6 files changed, 46 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
>  create mode 100644 drivers/net/ethernet/wangxun/libwx/wx_ethtool.h
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Andrew Lunn Feb. 13, 2023, 1:51 p.m. UTC | #2
On Mon, Feb 13, 2023 at 05:59:59PM +0800, Mengyuan Lou wrote:
> Add base ethtool ops get_drvinfo for ngbe and txgbe.

The netdev FAQ
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
says to wait at least 24 hours between new versions of patches, so
reviewers have time to review the code. Please make sure to address
the issues i pointed out in version 1 of you patch.

    Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/wangxun/libwx/Makefile b/drivers/net/ethernet/wangxun/libwx/Makefile
index 850d1615cd18..42ccd6e4052e 100644
--- a/drivers/net/ethernet/wangxun/libwx/Makefile
+++ b/drivers/net/ethernet/wangxun/libwx/Makefile
@@ -4,4 +4,4 @@ 
 
 obj-$(CONFIG_LIBWX) += libwx.o
 
-libwx-objs := wx_hw.o wx_lib.o
+libwx-objs := wx_hw.o wx_lib.o wx_ethtool.o
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
new file mode 100644
index 000000000000..1947b1f0481a
--- /dev/null
+++ b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
@@ -0,0 +1,27 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2015 - 2023 Beijing WangXun Technology Co., Ltd. */
+
+#include <linux/pci.h>
+#include <linux/phy.h>
+
+#include "wx_type.h"
+#include "wx_ethtool.h"
+
+static void wx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info)
+{
+	struct wx *wx = netdev_priv(netdev);
+
+	strscpy(info->driver, wx->driver_name, sizeof(info->driver));
+	strscpy(info->fw_version, wx->eeprom_id, sizeof(info->fw_version));
+	strscpy(info->bus_info, pci_name(wx->pdev), sizeof(info->bus_info));
+}
+
+static const struct ethtool_ops wx_ethtool_ops = {
+	.get_drvinfo		= wx_get_drvinfo,
+};
+
+void wx_set_ethtool_ops(struct net_device *netdev)
+{
+	netdev->ethtool_ops = &wx_ethtool_ops;
+}
+EXPORT_SYMBOL(wx_set_ethtool_ops);
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.h b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.h
new file mode 100644
index 000000000000..42c222e3210e
--- /dev/null
+++ b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.h
@@ -0,0 +1,9 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2015 - 2023 Beijing WangXun Technology Co., Ltd. */
+
+#ifndef _WX_ETHTOOL_H_
+#define _WX_ETHTOOL_H_
+
+void wx_set_ethtool_ops(struct net_device *netdev);
+
+#endif /* _WX_HW_H_ */
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h b/drivers/net/ethernet/wangxun/libwx/wx_type.h
index eede93d4120d..6d51b1e509d8 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_type.h
+++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h
@@ -633,6 +633,7 @@  struct wx {
 	bool adapter_stopped;
 	u16 tpid[8];
 	char eeprom_id[32];
+	char driver_name[32];
 	enum wx_reset_type reset_type;
 
 	/* PHY stuff */
diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
index f94d415daf3c..4d80ff8a0e5a 100644
--- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
+++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
@@ -14,6 +14,7 @@ 
 #include "../libwx/wx_type.h"
 #include "../libwx/wx_hw.h"
 #include "../libwx/wx_lib.h"
+#include "../libwx/wx_ethtool.h"
 #include "ngbe_type.h"
 #include "ngbe_mdio.h"
 #include "ngbe_hw.h"
@@ -546,6 +547,8 @@  static int ngbe_probe(struct pci_dev *pdev,
 		goto err_pci_release_regions;
 	}
 
+	strscpy(wx->driver_name, ngbe_driver_name, sizeof(wx->driver_name));
+	wx_set_ethtool_ops(netdev);
 	netdev->netdev_ops = &ngbe_netdev_ops;
 
 	netdev->features |= NETIF_F_HIGHDMA;
@@ -631,6 +634,8 @@  static int ngbe_probe(struct pci_dev *pdev,
 		etrack_id |= e2rom_ver;
 		wr32(wx, NGBE_EEPROM_VERSION_STORE_REG, etrack_id);
 	}
+	snprintf(wx->eeprom_id, sizeof(wx->eeprom_id),
+		 "0x%08x", etrack_id);
 
 	eth_hw_addr_set(netdev, wx->mac.perm_addr);
 	wx_mac_set_default_filter(wx, wx->mac.perm_addr);
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
index 094df377726b..f532137c283d 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
@@ -13,6 +13,7 @@ 
 #include "../libwx/wx_type.h"
 #include "../libwx/wx_lib.h"
 #include "../libwx/wx_hw.h"
+#include "../libwx/wx_ethtool.h"
 #include "txgbe_type.h"
 #include "txgbe_hw.h"
 
@@ -565,6 +566,8 @@  static int txgbe_probe(struct pci_dev *pdev,
 		goto err_pci_release_regions;
 	}
 
+	strscpy(wx->driver_name, txgbe_driver_name, sizeof(wx->driver_name));
+	wx_set_ethtool_ops(netdev);
 	netdev->netdev_ops = &txgbe_netdev_ops;
 
 	/* setup the private structure */