Message ID | 20211125020155.6488-1-xiangxia.m.yue@gmail.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,1/2] ifb: support ethtools driver info | expand |
On Thu, Nov 25, 2021 at 10:19 AM Jakub Kicinski <kuba@kernel.org> wrote: > > On Thu, 25 Nov 2021 10:01:54 +0800 xiangxia.m.yue@gmail.com wrote: > > +#define DRV_NAME "ifb" > > +#define DRV_VERSION "1.0" > > Let's not invent meaningless driver versions. Ok > > +#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)); > > Can we make core fill in driver name from rtnl_link_ops so we don't > need to do it in each driver? Good idea! v2 is sent out, please review. https://patchwork.kernel.org/project/netdevbpf/patch/20211125072544.32578-1-xiangxia.m.yue@gmail.com/ > > + strlcpy(info->version, DRV_VERSION, sizeof(info->version)); > > Leave this field as is, core should fill it with the kernel release. Ok > > +} -- Best regards, Tonghao
On Thu, Nov 25, 2021 at 10:01:54AM +0800, xiangxia.m.yue@gmail.com wrote: > 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" Please don't add this line too. Thanks
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);