[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211125020155.6488-1-xiangxia.m.yue@gmail.com>
Date: Thu, 25 Nov 2021 10:01:54 +0800
From: xiangxia.m.yue@...il.com
To: netdev@...r.kernel.org
Cc: Tonghao Zhang <xiangxia.m.yue@...il.com>,
Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>
Subject: [PATCH net-next 1/2] ifb: support ethtools driver info
From: Tonghao Zhang <xiangxia.m.yue@...il.com>
ifb netdev may be created by others prefix, not ifbX.
For getting netdev driver info, add ifb ethtools callback.
Cc: Jakub Kicinski <kuba@...nel.org>
Cc: "David S. Miller" <davem@...emloft.net>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@...il.com>
---
drivers/net/ifb.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 31f522b8e54e..d9078ce041c4 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -26,6 +26,7 @@
#include <linux/module.h>
#include <linux/kernel.h>
+#include <linux/ethtool.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/init.h>
@@ -35,7 +36,10 @@
#include <net/pkt_sched.h>
#include <net/net_namespace.h>
-#define TX_Q_LIMIT 32
+#define DRV_NAME "ifb"
+#define DRV_VERSION "1.0"
+#define TX_Q_LIMIT 32
+
struct ifb_q_private {
struct net_device *dev;
struct tasklet_struct ifb_tasklet;
@@ -181,6 +185,12 @@ static int ifb_dev_init(struct net_device *dev)
return 0;
}
+static void ifb_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+ strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
+ strlcpy(info->version, DRV_VERSION, sizeof(info->version));
+}
+
static const struct net_device_ops ifb_netdev_ops = {
.ndo_open = ifb_open,
.ndo_stop = ifb_close,
@@ -190,6 +200,10 @@ static const struct net_device_ops ifb_netdev_ops = {
.ndo_init = ifb_dev_init,
};
+static const struct ethtool_ops ifb_ethtool_ops = {
+ .get_drvinfo = ifb_get_drvinfo,
+};
+
#define IFB_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_FRAGLIST | \
NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ENCAP_ALL | \
NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_TX | \
@@ -224,6 +238,8 @@ static void ifb_setup(struct net_device *dev)
dev->vlan_features |= IFB_FEATURES & ~(NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX);
+ dev->ethtool_ops = &ifb_ethtool_ops;
+
dev->flags |= IFF_NOARP;
dev->flags &= ~IFF_MULTICAST;
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
@@ -289,7 +305,7 @@ static int ifb_validate(struct nlattr *tb[], struct nlattr *data[],
}
static struct rtnl_link_ops ifb_link_ops __read_mostly = {
- .kind = "ifb",
+ .kind = DRV_NAME,
.priv_size = sizeof(struct ifb_dev_private),
.setup = ifb_setup,
.validate = ifb_validate,
@@ -359,4 +375,4 @@ module_init(ifb_init_module);
module_exit(ifb_cleanup_module);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jamal Hadi Salim");
-MODULE_ALIAS_RTNL_LINK("ifb");
+MODULE_ALIAS_RTNL_LINK(DRV_NAME);
--
2.27.0
Powered by blists - more mailing lists