From: xiangxia.m.yue@gmail.com
To: netdev@vger.kernel.org
Cc: Tonghao Zhang <xiangxia.m.yue@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH net-next 1/2] ifb: support ethtools driver info
Date: Thu, 25 Nov 2021 10:01:54 +0800 [thread overview]
Message-ID: <20211125020155.6488-1-xiangxia.m.yue@gmail.com> (raw)
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
ifb netdev may be created by others prefix, not ifbX.
For getting netdev driver info, add ifb ethtools callback.
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.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
next reply other threads:[~2021-11-25 2:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 2:01 xiangxia.m.yue [this message]
2021-11-25 2:01 ` [PATCH net-next 2/2] ifb: support ethtools stats xiangxia.m.yue
2021-11-25 2:18 ` [PATCH net-next 1/2] ifb: support ethtools driver info Jakub Kicinski
2021-11-25 7:29 ` Tonghao Zhang
2021-11-25 13:55 ` Leon Romanovsky
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=20211125020155.6488-1-xiangxia.m.yue@gmail.com \
--to=xiangxia.m.yue@gmail.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/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