diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 3aaebb60a053..c99e8849ea18 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -161,6 +161,7 @@ struct ethtool_link_ksettings { #define ethtool_link_ksettings_test_link_mode(ptr, name, mode) \ test_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) +#ifdef CONFIG_ETHTOOL extern int __ethtool_get_link_ksettings(struct net_device *dev, struct ethtool_link_ksettings *link_ksettings); @@ -181,6 +182,33 @@ void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst, /* return false if src had higher bits set. lower bits always updated. */ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, const unsigned long *src); +#else +static inline int +__ethtool_get_link_ksettings(struct net_device *dev, + struct ethtool_link_ksettings *link_ksettings) +{ + return 0; +} + +static inline +void ethtool_intersect_link_masks(struct ethtool_link_ksettings *dst, + struct ethtool_link_ksettings *src) +{ +} + +static inline +void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst, + u32 legacy_u32) +{ +} + +static inline +bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, + const unsigned long *src) +{ + return false; +} +#endif /** * struct ethtool_ops - optional netdev operations diff --git a/net/Kconfig b/net/Kconfig index 49ccc280dc3d..e07cd33f574b 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -309,6 +309,13 @@ config BPF_STREAM_PARSER It can be used to enforce socket policy, implement socket redirects, etc. +config ETHTOOL + bool "enable ethtool" + default y + help + This selects ethtool function, default is Y. If say N, ethtool function + is not implemented. + config NET_FLOW_LIMIT bool depends on RPS diff --git a/net/core/Makefile b/net/core/Makefile index 80175e6a2eb8..5c1473391f36 100644 --- a/net/core/Makefile +++ b/net/core/Makefile @@ -8,11 +8,12 @@ obj-y := sock.o request_sock.o skbuff.o datagram.o stream.o scm.o \ obj-$(CONFIG_SYSCTL) += sysctl_net_core.o -obj-y += dev.o ethtool.o dev_addr_lists.o dst.o netevent.o \ +obj-y += dev.o dev_addr_lists.o dst.o netevent.o \ neighbour.o rtnetlink.o utils.o link_watch.o filter.o \ sock_diag.o dev_ioctl.o tso.o sock_reuseport.o \ fib_notifier.o xdp.o +obj-$(CONFIG_ETHTOOL) += ethtool.o obj-y += net-sysfs.o obj-$(CONFIG_PAGE_POOL) += page_pool.o obj-$(CONFIG_PROC_FS) += net-procfs.o diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index 90e8aa36881e..5650c0d96242 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -417,6 +417,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c *colon = ':'; return ret; +#ifdef CONFIG_ETHTOOL case SIOCETHTOOL: dev_load(net, ifr->ifr_name); rtnl_lock(); @@ -425,6 +426,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c if (colon) *colon = ':'; return ret; +#endif /* * These ioctl calls: diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 2597449ae9b4..f8647a382fd6 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -243,6 +243,7 @@ static int proc_do_dev_weight(struct ctl_table *table, int write, return ret; } +#ifdef CONFIG_ETHTOOL static int proc_do_rss_key(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { @@ -254,6 +255,7 @@ static int proc_do_rss_key(struct ctl_table *table, int write, fake_table.maxlen = sizeof(buf); return proc_dostring(&fake_table, write, buffer, lenp, ppos); } +#endif #ifdef CONFIG_BPF_JIT static int proc_dointvec_minmax_bpf_enable(struct ctl_table *table, int write, @@ -368,6 +370,7 @@ static struct ctl_table net_core_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, +#ifdef CONFIG_ETHTOOL { .procname = "netdev_rss_key", .data = &netdev_rss_key, @@ -375,6 +378,7 @@ static struct ctl_table net_core_table[] = { .mode = 0444, .proc_handler = proc_do_rss_key, }, +#endif #ifdef CONFIG_BPF_JIT { .procname = "bpf_jit_enable",