net: Unified offload configuration
Subsystems (3)
v6 cover net: Unified offload configuration
Here's a v6 of the ethtool unification patch series.
What's in it?
1..4:
cleanups for the core patches
5:
the patch - implement unified ethtool setting ops
6..7:
implement interoperation between old and new ethtool ops
8:
include RX checksum in features and plug it into new framework
9:
convert loopback device to new framework
What is it good for?
- unifies driver behaviour wrt hardware offloads
- removes a lot of boilerplate code from drivers
- allows better fine-grained control over used offloads
This version is not tested, yet.
Best Regards,
Michał Mirosław
v1: http://marc.info/?l=linux-netdev&m=129245188832643&w=3
Changes from v5:
- register_netdevice(): avoid warning on GSO for non-SG capable devices
- rebased on current net-next (introduction of ndo_add/del_slave)
Changes from v4:
- more split cleanups
- fix error return for ETHTOOL_SFLAGS
- fix ETHTOOL_G* compatibility for not converted drivers
Changes from v3:
- fixed kernel-doc and other comments
- added HIGHDMA to never-changeable features
- changed GFEATURES .size interpretation
- changed feature strings
- change __ethtool_set_flags() to reject invalid changes
Changes from v2:
- rebase to net-next after merging v2 leading patches
- fix missing comma in feature name table
- force NETIF_F_SOFT_FEATURES in hw_features for simpler code (fixes a bug that disallowed changing GSO and GRO state)
Changes from v1:
- split structures for GFEATURES/SFEATURES
- naming of feature bits using GSTRINGS ETH_SS_FEATURES
- strict checking of bits used in SFEATURES call
- more comments and kernel-doc
- rebased to net-next after 2.6.37
---
Michał Mirosław (9):
ethtool: move EXPORT_SYMBOL(ethtool_op_set_tx_csum) to correct place
ethtool: enable GSO and GRO by default
ethtool: factorize ethtool_get_strings() and ethtool_get_sset_count()
ethtool: factorize get/set_one_feature
net: Introduce new feature setting ops
net: ethtool: use ndo_fix_features for offload setting
net: use ndo_fix_features for ethtool_ops->set_flags
net: introduce NETIF_F_RXCSUM
loopback: convert to hw_features
drivers/net/loopback.c | 9 +- include/linux/ethtool.h | 86 ++++++++- include/linux/netdevice.h | 49 ++++- net/core/dev.c | 52 ++++- net/core/ethtool.c | 527 +++++++++++++++++++++++++++++--------------- 5 files changed, 531 insertions(+), 192 deletions(-)
Signature · 1 line
1.7.2.3
PATCH v6 1/9 ethtool: move EXPORT_SYMBOL(ethtool_op_set_tx_csum) to correct place
--- net/core/ethtool.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/core/ethtool.c +1 -1
@@ -55,6 +55,7 @@ int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)return 0 ; } +EXPORT_SYMBOL (ethtool_op_set_tx_csum);int ethtool_op_set_tx_hw_csum (struct net_device *dev,u32 data) {
@@ -1124,7 +1125,6 @@ static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)return dev->ethtool_ops->set_tx_csum (dev, edata.data); } -EXPORT_SYMBOL (ethtool_op_set_tx_csum);static int ethtool_set_rx_csum (struct net_device *dev,char __user *useraddr) {
Signature · 1 line
1.7.2.3
PATCH v6 2/9 ethtool: enable GSO and GRO by default
In reply to Michał Mirosław--- include/linux/netdevice.h | 3 +++ net/core/dev.c | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-)
include/linux/netdevice.h +3 -0
@@ -984,6 +984,9 @@ struct net_device { NETIF_F_SG | NETIF_F_HIGHDMA | \ NETIF_F_FRAGLIST) +/* changeable features with no special hardware requirements */ +#define NETIF_F_SOFT_FEATURES (NETIF_F_GSO | NETIF_F_GRO) +/* Interface index. Unique device identifier */ int ifindex;int iflink;
net/core/dev.c +14 -4
@@ -5274,6 +5274,12 @@ u32 netdev_fix_features(struct net_device *dev, u32 features) features &= ~NETIF_F_TSO ; } +/* Software GSO depends on SG. */ +if ((features &NETIF_F_GSO ) && !(features &NETIF_F_SG )) { +netdev_info (dev,"Dropping NETIF_F_GSO since no SG feature.\n" ); + features &= ~NETIF_F_GSO ; + } +/* UFO needs SG and checksumming */ if (features &NETIF_F_UFO ) {/* maybe split UFO into V4 and V6? */
@@ -5430,12 +5436,16 @@ int register_netdevice(struct net_device *dev)if (dev->iflink ==-1 ) dev->iflink = dev->ifindex; +/* Enable software offloads by default - will be stripped in +* netdev_fix_features() if not supported. */ + dev->features |=NETIF_F_SOFT_FEATURES ; + +/* Avoid warning from netdev_fix_features() for GSO without SG */ +if (!(dev->features &NETIF_F_SG )) + dev->features &= ~NETIF_F_GSO ; + dev->features =netdev_fix_features (dev, dev->features); -/* Enable software GSO if SG is supported. */ -if (dev->features &NETIF_F_SG ) - dev->features |=NETIF_F_GSO ; -/* Enable GRO and NETIF_F_HIGHDMA for vlans by default, * vlan_dev_init() will do the dev->features check, so these features * are enabled only if supported by underlying device.
Signature · 1 line
1.7.2.3
PATCH v6 3/9 ethtool: factorize ethtool_get_strings() and ethtool_get_sset_count()
In reply to Michał MirosławThis is needed for unified offloads patch.
--- net/core/ethtool.c | 35 +++++++++++++++++++++++------------ 1 files changed, 23 insertions(+), 12 deletions(-)
net/core/ethtool.c +23 -12
@@ -172,6 +172,25 @@ EXPORT_SYMBOL(ethtool_ntuple_flush);/* Handlers for each ethtool command */ +static int __ethtool_get_sset_count (struct net_device *dev,int sset) +{ +const struct ethtool_ops *ops = dev->ethtool_ops; + +if (ops && ops->get_sset_count && ops->get_strings) +return ops->get_sset_count (dev, sset); +else +return -EOPNOTSUPP ; +} + +static void __ethtool_get_strings (struct net_device *dev, +u32 stringset,u8 *data) +{ +const struct ethtool_ops *ops = dev->ethtool_ops; + +/* ops->get_strings is valid because checked earlier */ + ops->get_strings (dev, stringset, data); +} +static int ethtool_get_settings (struct net_device *dev,void __user *useraddr) {struct ethtool_cmd cmd = { .cmd =ETHTOOL_GSET };
@@ -252,14 +271,10 @@ static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev, void __user *useraddr) {struct ethtool_sset_info info; -const struct ethtool_ops *ops = dev->ethtool_ops;u64 sset_mask;int i, idx =0 , n_bits =0 , ret, rc;u32 *info_buf =NULL ; -if (!ops->get_sset_count) -return -EOPNOTSUPP ; -if (copy_from_user (&info, useraddr,sizeof (info)))return -EFAULT ;
@@ -286,7 +301,7 @@ static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev,if (!(sset_mask & (1ULL << i)))continue ; - rc = ops->get_sset_count (dev, i); + rc =__ethtool_get_sset_count (dev, i);if (rc >=0 ) { info.sset_mask |= (1ULL << i); info_buf[idx++] = rc;
@@ -1287,17 +1302,13 @@ static int ethtool_self_test(struct net_device *dev, char __user *useraddr)static int ethtool_get_strings (struct net_device *dev,void __user *useraddr) {struct ethtool_gstrings gstrings; -const struct ethtool_ops *ops = dev->ethtool_ops;u8 *data;int ret; -if (!ops->get_strings || !ops->get_sset_count) -return -EOPNOTSUPP ; -if (copy_from_user (&gstrings, useraddr,sizeof (gstrings)))return -EFAULT ; - ret = ops->get_sset_count (dev, gstrings.string_set); + ret =__ethtool_get_sset_count (dev, gstrings.string_set);if (ret <0 )return ret;
@@ -1307,7 +1318,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)if (!data)return -ENOMEM ; - ops->get_strings (dev, gstrings.string_set, data); +__ethtool_get_strings (dev, gstrings.string_set, data); ret = -EFAULT ;if (copy_to_user (useraddr, &gstrings,sizeof (gstrings)))
@@ -1317,7 +1328,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr) goto out; ret =0 ; - out: +out:kfree (data);return ret; }
Signature · 1 line
1.7.2.3
PATCH v6 4/9 ethtool: factorize get/set_one_feature
In reply to Michał MirosławThis allows to enable GRO even if RX csum is disabled. GRO will not be used for packets without hardware checksum anyway.
--- include/linux/netdevice.h | 6 + net/core/ethtool.c | 274 ++++++++++++++++++++++----------------------- 2 files changed, 138 insertions(+), 142 deletions(-)
include/linux/netdevice.h +6 -0
@@ -976,6 +976,12 @@ struct net_device {#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)#define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM) +#define NETIF_F_ALL_TSO (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN) + +#define NETIF_F_ALL_TX_OFFLOADS (NETIF_F_ALL_CSUM | NETIF_F_SG | \ + NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | \ + NETIF_F_SCTP_CSUM | NETIF_F_FCOE_CRC) +/* * If one device supports one of these features, then enable them * for all in netdev_increment_features.
net/core/ethtool.c +132 -142
348 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH v6 5/9 net: Introduce new feature setting ops
In reply to Michał MirosławThis introduces a new framework to handle device features setting. It consists of:
- new fields in struct net_device:
+ hw_features - features that hw/driver supports toggling
+ wanted_features - features that user wants enabled, when possible
- new netdev_ops:
+ feat = ndo_fix_features(dev, feat) - API checking constraints for enabling features or their combinations
+ ndo_set_features(dev) - API updating hardware state to match changed dev->features
- new ethtool commands:
+ ETHTOOL_GFEATURES/ETHTOOL_SFEATURES: get/set dev->wanted_features and trigger device reconfiguration if resulting dev->features changed
+ ETHTOOL_GSTRINGS(ETH_SS_FEATURES): get feature bits names (meaning)
--- include/linux/ethtool.h | 85 ++++++++++++++++++++++++++++++ include/linux/netdevice.h | 37 +++++++++++++- net/core/dev.c | 46 ++++++++++++++-- net/core/ethtool.c | 125 ++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 283 insertions(+), 10 deletions(-)
include/linux/ethtool.h +85 -0
@@ -251,6 +251,7 @@ enum ethtool_stringset {ETH_SS_STATS ,ETH_SS_PRIV_FLAGS ,ETH_SS_NTUPLE_FILTERS , + ETH_SS_FEATURES, };/* for passing string sets for data tagging */
@@ -523,6 +524,87 @@ struct ethtool_flash {char data[ETHTOOL_FLASH_MAX_FILENAME ]; }; +/* for returning and changing feature sets */ + +/** +* struct ethtool_get_features_block - block with state of 32 features +* @available: mask of changeable features +* @requested: mask of features requested to be enabled if possible +* @active: mask of currently enabled features +* @never_changed: mask of features not changeable for any device +*/ +struct ethtool_get_features_block { +__u32 available; +__u32 requested; +__u32 active; +__u32 never_changed; +}; + +/** +* struct ethtool_gfeatures - command to get state of device's features +* @cmd: command number = %ETHTOOL_GFEATURES +* @size: in: number of elements in the features[] array; +* out: number of elements in features[] needed to hold all features +* @features: state of features +*/ +struct ethtool_gfeatures { +__u32 cmd; +__u32 size; +struct ethtool_get_features_block features[0 ]; +}; + +/** +* struct ethtool_set_features_block - block with request for 32 features +* @valid: mask of features to be changed +* @requested: values of features to be changed +*/ +struct ethtool_set_features_block { +__u32 valid; +__u32 requested; +}; + +/** +* struct ethtool_sfeatures - command to request change in device's features +* @cmd: command number = %ETHTOOL_SFEATURES +* @size: array size of the features[] array +* @features: feature change masks +*/ +struct ethtool_sfeatures { +__u32 cmd; +__u32 size; +struct ethtool_set_features_block features[0 ]; +}; + +/* +* %ETHTOOL_SFEATURES changes features present in features[].valid to the +* values of corresponding bits in features[].requested. Bits in .requested +* not set in .valid or not changeable are ignored. +* +* Returns %EINVAL when .valid contains undefined or never-changable bits +* or size is not equal to required number of features words (32-bit blocks). +* Returns >= 0 if request was completed; bits set in the value mean: +* %ETHTOOL_F_UNSUPPORTED - there were bits set in .valid that are not +* changeable (not present in %ETHTOOL_GFEATURES' features[].available) +* those bits were ignored. +* %ETHTOOL_F_WISH - some or all changes requested were recorded but the +* resulting state of bits masked by .valid is not equal to .requested. +* Probably there are other device-specific constraints on some features +* in the set. When %ETHTOOL_F_UNSUPPORTED is set, .valid is considered +* here as though ignored bits were cleared. +* +* Meaning of bits in the masks are obtained by %ETHTOOL_GSSET_INFO (number of +* bits in the arrays - always multiple of 32) and %ETHTOOL_GSTRINGS commands +* for ETH_SS_FEATURES string set. First entry in the table corresponds to least +* significant bit in features[0] fields. Empty strings mark undefined features. +*/ +enum ethtool_sfeatures_retval_bits { +ETHTOOL_F_UNSUPPORTED__BIT , +ETHTOOL_F_WISH__BIT , +}; + +#define ETHTOOL_F_UNSUPPORTED (1 << ETHTOOL_F_UNSUPPORTED__BIT) +#define ETHTOOL_F_WISH (1 << ETHTOOL_F_WISH__BIT) +#ifdef __KERNEL__#include <linux/rculist.h>
@@ -744,6 +826,9 @@ struct ethtool_ops {#define ETHTOOL_GRXFHINDIR 0x00000038/* Get RX flow hash indir'n table */ #define ETHTOOL_SRXFHINDIR 0x00000039/* Set RX flow hash indir'n table */ +#define ETHTOOL_GFEATURES 0x0000003a/* Get device offload settings */ +#define ETHTOOL_SFEATURES 0x0000003b/* Change device offload settings */ +/* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET#define SPARC_ETH_SSET ETHTOOL_SSET
include/linux/netdevice.h +35 -2
@@ -791,6 +791,18 @@ struct netdev_tc_txq {* * int (*ndo_del_slave)(struct net_device *dev, struct net_device *slave_dev); * Called to release previously enslaved netdev. +* +* Feature/offload setting functions. +* u32 (*ndo_fix_features)(struct net_device *dev, u32 features); +* Adjusts the requested feature flags according to device-specific +* constraints, and returns the resulting flags. Must not modify +* the device state. +* +* int (*ndo_set_features)(struct net_device *dev, u32 features); +* Called to update device configuration to new features. Passed +* feature set might be less than what was returned by ndo_fix_features()). +* Must return >0 or -errno if it changed dev->features itself. +* */ #define HAVE_NET_DEVICE_OPS struct net_device_ops {
@@ -874,6 +886,10 @@ struct net_device_ops { struct net_device *slave_dev);int (*ndo_del_slave)(struct net_device *dev,struct net_device *slave_dev); +u32 (*ndo_fix_features)(struct net_device *dev, +u32 features); +int (*ndo_set_features)(struct net_device *dev, +u32 features); };/*
@@ -925,12 +941,18 @@ struct net_device {struct list_head napi_list;struct list_head unreg_list; -/* Net device features */ +/* currently active device features */ u32 features; - +/* user-changeable features */ +u32 hw_features; +/* user-requested features */ +u32 wanted_features;/* VLAN feature mask */ u32 vlan_features; +/* Net device feature bits; if you change something, +* also update netdev_features_strings[] in ethtool.c */ +#define NETIF_F_SG 1/* Scatter/gather IO. */ #define NETIF_F_IP_CSUM 2/* Can checksum TCP/UDP over IPv4. */ #define NETIF_F_NO_CSUM 4/* Does not require checksum. F.e. loopack. */
@@ -966,6 +988,12 @@ struct net_device {#define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)#define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) +/* Features valid for ethtool to change */ +/* = all defined minus driver/device-class-related */ +#define NETIF_F_NEVER_CHANGE (NETIF_F_HIGHDMA | NETIF_F_VLAN_CHALLENGED | \ + NETIF_F_LLTX | NETIF_F_NETNS_LOCAL) +#define NETIF_F_ETHTOOL_BITS (0x1f3fffff & ~NETIF_F_NEVER_CHANGE) +/* List of features with software fallbacks. */ #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ NETIF_F_TSO6 | NETIF_F_UFO)
@@ -2428,8 +2456,13 @@ extern char *netdev_drivername(const struct net_device *dev, char *buffer, int lextern void linkwatch_run_queue (void ); +static inline u32 netdev_get_wanted_features (struct net_device *dev) +{ +return (dev->features & ~dev->hw_features) | dev->wanted_features; +}u32 netdev_increment_features (u32 all,u32 one,u32 mask);u32 netdev_fix_features (struct net_device *dev,u32 features); +void netdev_update_features (struct net_device *dev);void netif_stacked_transfer_operstate (const struct net_device *rootdev,struct net_device *dev);
net/core/dev.c +40 -6
61 lines not on this page · raw message
net/core/ethtool.c +123 -2
153 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH v6 6/9 net: ethtool: use ndo_fix_features for offload setting
In reply to Michał Mirosław--- net/core/ethtool.c | 45 ++++++++++++++++++++++++++++++++------------- 1 files changed, 32 insertions(+), 13 deletions(-)
net/core/ethtool.c +32 -13
@@ -357,15 +357,21 @@ static void *__ethtool_get_one_feature_actor(struct net_device *dev, u32 ethcmd)static int ethtool_get_one_feature (struct net_device *dev,char __user *useraddr,u32 ethcmd) { +u32 mask =ethtool_get_feature_mask (ethcmd);struct ethtool_value edata = { .cmd = ethcmd, - .data = !!(dev->features ðtool_get_feature_mask (ethcmd)), + .data = !!(dev->features & mask), }; -u32 (*actor)(struct net_device *); - actor =__ethtool_get_one_feature_actor (dev, ethcmd); -if (actor) - edata.data =actor (dev); +/* compatibility with discrete get_ ops */ +if (!(dev->hw_features & mask)) { +u32 (*actor)(struct net_device *); + + actor =__ethtool_get_one_feature_actor (dev, ethcmd); + +if (actor) + edata.data =actor (dev); + }if (copy_to_user (useraddr, &edata,sizeof (edata)))return -EFAULT ;
@@ -386,6 +392,27 @@ static int ethtool_set_one_feature(struct net_device *dev,if (copy_from_user (&edata, useraddr,sizeof (edata)))return -EFAULT ; + mask =ethtool_get_feature_mask (ethcmd); + mask &= dev->hw_features; +if (mask) { +if (edata.data) + dev->wanted_features |= mask; +else + dev->wanted_features &= ~mask; + +netdev_update_features (dev); +return 0 ; + } + +/* Driver is not converted to ndo_fix_features or does not +* support changing this offload. In the latter case it won't +* have corresponding ethtool_ops field set. +* +* Following part is to be removed after all drivers advertise +* their changeable features in netdev->hw_features and stop +* using discrete offload setting ops. +*/ +switch (ethcmd) {case ETHTOOL_STXCSUM :return __ethtool_set_tx_csum (dev, edata.data);
@@ -395,14 +422,6 @@ static int ethtool_set_one_feature(struct net_device *dev,return __ethtool_set_tso (dev, edata.data);case ETHTOOL_SUFO :return __ethtool_set_ufo (dev, edata.data); -case ETHTOOL_SGSO : -case ETHTOOL_SGRO : - mask =ethtool_get_feature_mask (ethcmd); -if (edata.data) - dev->features |= mask; -else - dev->features &= ~mask; -return 0 ;default :return -EOPNOTSUPP ; }
Signature · 1 line
1.7.2.3
PATCH v6 7/9 net: use ndo_fix_features for ethtool_ops->set_flags
In reply to Michał Mirosław--- net/core/ethtool.c | 31 +++++++++++++++++++++++++++++-- 1 files changed, 29 insertions(+), 2 deletions(-)
net/core/ethtool.c +29 -2
@@ -427,6 +427,34 @@ static int ethtool_set_one_feature(struct net_device *dev, } } +static int __ethtool_set_flags (struct net_device *dev,u32 data) +{ +u32 changed; + +if (data & ~flags_dup_features) +return -EINVAL ; + +/* legacy set_flags() op */ +if (dev->ethtool_ops->set_flags) { +if (unlikely (dev->hw_features & flags_dup_features)) +netdev_warn (dev, +"driver BUG: mixed hw_features and set_flags()\n" ); +return dev->ethtool_ops->set_flags (dev, data); + } + +/* allow changing only bits set in hw_features */ + changed = (data ^ dev->wanted_features) & flags_dup_features; +if (changed & ~dev->hw_features) +return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP ; + + dev->wanted_features = + (dev->wanted_features & ~changed) | data; + +netdev_update_features (dev); + +return 0 ; +} +static int ethtool_get_settings (struct net_device *dev,void __user *useraddr) {struct ethtool_cmd cmd = { .cmd =ETHTOOL_GSET };
@@ -1768,8 +1796,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) ethtool_op_get_flags));break ;case ETHTOOL_SFLAGS : - rc =ethtool_set_value (dev, useraddr, - dev->ethtool_ops->set_flags); + rc =ethtool_set_value (dev, useraddr, __ethtool_set_flags);break ;case ETHTOOL_GPFLAGS : rc = ethtool_get_value(dev, useraddr, ethcmd,
Signature · 1 line
1.7.2.3
PATCH v6 8/9 net: introduce NETIF_F_RXCSUM
In reply to Michał MirosławIntroduce NETIF_F_RXCSUM to replace device-private flags for RX checksum offload. Integrate it with ndo_fix_features.
ethtool_op_get_rx_csum() is removed altogether as nothing in-tree uses it.
--- include/linux/ethtool.h | 1 - include/linux/netdevice.h | 5 +++- net/core/ethtool.c | 47 ++++++++++++++++++++++----------------------- 3 files changed, 27 insertions(+), 26 deletions(-)
include/linux/ethtool.h +0 -1
@@ -625,7 +625,6 @@ struct net_device;/* Some generic methods drivers may use in their ethtool_ops */ u32 ethtool_op_get_link (struct net_device *dev); -u32 ethtool_op_get_rx_csum (struct net_device *dev);u32 ethtool_op_get_tx_csum (struct net_device *dev);int ethtool_op_set_tx_csum (struct net_device *dev,u32 data);int ethtool_op_set_tx_hw_csum (struct net_device *dev,u32 data);
include/linux/netdevice.h +4 -1
@@ -977,6 +977,7 @@ struct net_device {#define NETIF_F_FCOE_MTU (1 << 26)/* Supports max FCoE MTU, 2158 bytes*/ #define NETIF_F_NTUPLE (1 << 27)/* N-tuple filters supported */ #define NETIF_F_RXHASH (1 << 28)/* Receive hashing offload */ +#define NETIF_F_RXCSUM (1 << 29)/* Receive checksumming offload */ /* Segmentation offload features */ #define NETIF_F_GSO_SHIFT 16
@@ -992,7 +993,7 @@ struct net_device {/* = all defined minus driver/device-class-related */ #define NETIF_F_NEVER_CHANGE (NETIF_F_HIGHDMA | NETIF_F_VLAN_CHALLENGED | \ NETIF_F_LLTX | NETIF_F_NETNS_LOCAL) -#define NETIF_F_ETHTOOL_BITS (0x1f3fffff & ~NETIF_F_NEVER_CHANGE) +#define NETIF_F_ETHTOOL_BITS (0x3f3fffff & ~NETIF_F_NEVER_CHANGE)/* List of features with software fallbacks. */ #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \
@@ -2510,6 +2511,8 @@ static inline int dev_ethtool_get_settings(struct net_device *dev,static inline u32 dev_ethtool_get_rx_csum (struct net_device *dev) { +if (dev->hw_features &NETIF_F_RXCSUM ) +return !!(dev->features &NETIF_F_RXCSUM );if (!dev->ethtool_ops || !dev->ethtool_ops->get_rx_csum)return 0 ;return dev->ethtool_ops->get_rx_csum (dev);
net/core/ethtool.c +23 -24
125 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH v6 9/9 loopback: convert to hw_features
In reply to Michał MirosławThis also enables TSOv6, TSO-ECN, and UFO as loopback clearly can handle them.
--- drivers/net/loopback.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
drivers/net/loopback.c +4 -5
@@ -129,10 +129,6 @@ static u32 always_on(struct net_device *dev)static const struct ethtool_ops loopback_ethtool_ops = { .get_link = always_on, - .set_tso = ethtool_op_set_tso, - .get_tx_csum = always_on, - .get_sg = always_on, - .get_rx_csum = always_on, };static int loopback_dev_init (struct net_device *dev)
@@ -169,9 +165,12 @@ static void loopback_setup(struct net_device *dev) dev->type =ARPHRD_LOOPBACK ;/* 0x0001*/ dev->flags =IFF_LOOPBACK ; dev->priv_flags &= ~IFF_XMIT_DST_RELEASE ; + dev->hw_features =NETIF_F_ALL_TSO |NETIF_F_UFO ; dev->features =NETIF_F_SG |NETIF_F_FRAGLIST - |NETIF_F_TSO + |NETIF_F_ALL_TSO + |NETIF_F_UFO |NETIF_F_NO_CSUM + |NETIF_F_RXCSUM |NETIF_F_HIGHDMA |NETIF_F_LLTX |NETIF_F_NETNS_LOCAL ;
Signature · 1 line
1.7.2.3
From: Michał Mirosław <[email protected]>
Date: Wed, 16 Feb 2011 03:59:16 +0100 (CET)
Quoted 14 lines
Here's a v6 of the ethtool unification patch series.
What's in it?
1..4:
cleanups for the core patches
5:
the patch - implement unified ethtool setting ops
6..7:
implement interoperation between old and new ethtool ops
8:
include RX checksum in features and plug it into new framework
9:
convert loopback device to new framework
Quoted 4 lines
What is it good for?
- unifies driver behaviour wrt hardware offloads
- removes a lot of boilerplate code from drivers
- allows better fine-grained control over used offloads
Applied to net-next-2.6, please send any bug fixes relative to this.
Please get rid of that annoying message spit out by netif_features_change(), it's just spam. If we want notifications for stuff like this, use a non-unicast netlink message so those who want to hear it can do so.
Quoted 20 lines · David Miller
From: Michał Mirosław <[email protected]>
Date: Wed, 16 Feb 2011 03:59:16 +0100 (CET)Quoted 14 lines
Here's a v6 of the ethtool unification patch series.
What's in it?
1..4:
cleanups for the core patches
5:
the patch - implement unified ethtool setting ops
6..7:
implement interoperation between old and new ethtool ops
8:
include RX checksum in features and plug it into new framework
9:
convert loopback device to new frameworkQuoted 4 lines
What is it good for?
- unifies driver behaviour wrt hardware offloads
- removes a lot of boilerplate code from drivers
- allows better fine-grained control over used offloads
Quoted 5 lines
Applied to net-next-2.6, please send any bug fixes relative to this.
Please get rid of that annoying message spit out by
netif_features_change(), it's just spam. If we want notifications for stuff like this, use a non-unicast netlink message so those who want to hear it can do so.
You mean netdev_update_features() "Features changed" message? Is it ok to just demote it to DEBUG level or you want to remove it altogether? What about netdev_fix_features() messages?
Best Regards,
Michał Mirosław
Quoted 1 line · Michał Mirosław
On Thu, Feb 17, 2011 at 02:56:11PM -0800, David Miller wrote:
[...]
Quoted 7 lines
Quoted 3 lines
Please get rid of that annoying message spit out by
netif_features_change(), it's just spam. If we want notifications for stuff like this, use a non-unicast netlink message so those who want to hear it can do so.You mean
netdev_update_features()"Features changed" message? Is it ok to just demote it to DEBUG level or you want to remove it altogether? What aboutnetdev_fix_features()messages?
I think you need to emit these messages at 'error' severity when fixing up features for a newly-added device, but at 'debug' later on.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 11 lines · Ben Hutchings
Quoted 1 line · Michał Mirosław
On Thu, Feb 17, 2011 at 02:56:11PM -0800, David Miller wrote:
[...]
Quoted 6 lines
Quoted 3 lines
Please get rid of that annoying message spit out by
netif_features_change(), it's just spam. If we want notifications for stuff like this, use a non-unicast netlink message so those who want to hear it can do so.You mean
netdev_update_features()"Features changed" message? Is it ok to just demote it to DEBUG level or you want to remove it altogether? What aboutnetdev_fix_features()messages?I think you need to emit these messages at 'error' severity when fixing up features for a newly-added device, but at 'debug' later on.
Why the difference? Those messages on startup matter mostly to developers and later mostly to users. Anyway, the conditions in netdev_fix_features() are all constant (dependent only on net core implementation).
Best Regards,
Michał Mirosław
David Miller
maintainerFrom: Ben Hutchings <[email protected]>
Date: Fri, 18 Feb 2011 14:29:31 +0000
Quoted 7 lines · Michał Mirosław
Quoted 1 line · David Miller
[...]
Quoted 4 lines
Quoted 3 lines
Please get rid of that annoying message spit out by
netif_features_change(), it's just spam. If we want notifications for stuff like this, use a non-unicast netlink message so those who want to hear it can do so.
Quoted 6 lines
Quoted 3 lines
You mean
netdev_update_features()"Features changed" message? Is it ok to just demote it to DEBUG level or you want to remove it altogether? What aboutnetdev_fix_features()messages?I think you need to emit these messages at 'error' severity when fixing up features for a newly-added device, but at 'debug' later on.
I get one several minutes after every boot for a completely unregistered device for some reason:
[119704.730965] (unregistered net_device): Features changed: 0x00011065 -> 0x00015065
Quoted 12 lines · David Miller
From: Ben Hutchings <[email protected]>
Date: Fri, 18 Feb 2011 14:29:31 +0000Quoted 9 lines · Michał Mirosław
Quoted 1 line · David Miller
[...]
Quoted 6 lines
Quoted 3 lines
Please get rid of that annoying message spit out by
netif_features_change(), it's just spam. If we want notifications for stuff like this, use a non-unicast netlink message so those who want to hear it can do so.You mean
netdev_update_features()"Features changed" message? Is it ok to just demote it to DEBUG level or you want to remove it altogether? What aboutnetdev_fix_features()messages?
Quoted 6 lines
Quoted 2 lines
I think you need to emit these messages at 'error' severity when fixing up features for a newly-added device, but at 'debug' later on.
I get one several minutes after every boot for a completely unregistered device for some reason:
[119704.730965] (unregistered net_device): Features changed: 0x00011065 -> 0x00015065
Hmm. That's because netdev_update_features() get's called before changing netdev->reg_state. I wonder if moving the feature update just after "dev->reg_state = NETREG_REGISTERED;" will be correct fix.
Best Regards,
Michał Mirosław
PATCH 1/1 Fix "(unregistered net_device): Features changed" message
Fix netdev_update_features() messages on register time by moving the call further in register_netdevice(). When netdev->reg_state != NETREG_REGISTERED, netdev_name() returns "(unregistered netdevice)" even if the dev's name is already filled.
--- net/core/dev.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/core/dev.c +2 -2
@@ -5478,8 +5478,6 @@ int register_netdevice(struct net_device *dev)if (!(dev->wanted_features &NETIF_F_SG )) dev->wanted_features &= ~NETIF_F_GSO ; -netdev_update_features (dev); -/* Enable GRO and NETIF_F_HIGHDMA for vlans by default, * vlan_dev_init() will do the dev->features check, so these features * are enabled only if supported by underlying device.
@@ -5496,6 +5494,8 @@ int register_netdevice(struct net_device *dev) goto err_uninit; dev->reg_state =NETREG_REGISTERED ; +netdev_update_features (dev); +/* * Default initial state at registry is that the * device is present.
Signature · 1 line
1.7.2.3
PATCH 1/1 net: avoid initial "Features changed" message
In reply to David MillerAvoid "Features changed" message and ndo_set_features call on device registration caused by automatic enabling of GSO and GRO. Driver should have already enabled hardware offloads it set in features, so the ndo_set_features() is not needed at registration time unless features change because of other dependencies.
--- net/core/dev.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
net/core/dev.c +5 -3
@@ -5475,12 +5475,14 @@ int register_netdevice(struct net_device *dev)* software offloads (GSO and GRO). */ dev->hw_features |=NETIF_F_SOFT_FEATURES ; - dev->wanted_features = (dev->features & dev->hw_features) - |NETIF_F_SOFT_FEATURES ; + dev->features |=NETIF_F_SOFT_FEATURES ; + dev->wanted_features = dev->features & dev->hw_features;/* Avoid warning from netdev_fix_features() for GSO without SG */ -if (!(dev->wanted_features &NETIF_F_SG )) +if (!(dev->wanted_features &NETIF_F_SG )) { dev->wanted_features &= ~NETIF_F_GSO ; + dev->features &= ~NETIF_F_GSO ; + }/* Enable GRO and NETIF_F_HIGHDMA for vlans by default, * vlan_dev_init() will do the dev->features check, so these features
Signature · 1 line
1.7.2.3
Re: [PATCH] net: avoid initial "Features changed" message
Quoted 5 lines · Michał Mirosław
Avoid "Features changed" message and
ndo_set_featurescall on device registration caused by automatic enabling of GSO and GRO. Driver should have already enabled hardware offloads it set in features, so thendo_set_features()is not needed at registration time unless features change because of other dependencies.
[cut patch]
Ah. This depends on 'Fix "(unregistered net_device): Features changed" message' patch I sent couple days ago.
Best Regards,
Michał Mirosław