diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-02-15 11:59:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-02-17 17:16:33 -0500 |
commit | 5455c6998d34dc983a8693500e4dffefc3682dc5 (patch) | |
tree | b765aecf6d33d8c550cde78368ccc8654951ec07 /include/linux/netdevice.h | |
parent | 0a417704777ed29d0e8c72b7274a328e61248e75 (diff) |
net: Introduce new feature setting ops
This 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)
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index dede3fdbb4be..85f67e225f60 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -791,6 +791,18 @@ struct netdev_tc_txq { | |||
791 | * | 791 | * |
792 | * int (*ndo_del_slave)(struct net_device *dev, struct net_device *slave_dev); | 792 | * int (*ndo_del_slave)(struct net_device *dev, struct net_device *slave_dev); |
793 | * Called to release previously enslaved netdev. | 793 | * Called to release previously enslaved netdev. |
794 | * | ||
795 | * Feature/offload setting functions. | ||
796 | * u32 (*ndo_fix_features)(struct net_device *dev, u32 features); | ||
797 | * Adjusts the requested feature flags according to device-specific | ||
798 | * constraints, and returns the resulting flags. Must not modify | ||
799 | * the device state. | ||
800 | * | ||
801 | * int (*ndo_set_features)(struct net_device *dev, u32 features); | ||
802 | * Called to update device configuration to new features. Passed | ||
803 | * feature set might be less than what was returned by ndo_fix_features()). | ||
804 | * Must return >0 or -errno if it changed dev->features itself. | ||
805 | * | ||
794 | */ | 806 | */ |
795 | #define HAVE_NET_DEVICE_OPS | 807 | #define HAVE_NET_DEVICE_OPS |
796 | struct net_device_ops { | 808 | struct net_device_ops { |
@@ -874,6 +886,10 @@ struct net_device_ops { | |||
874 | struct net_device *slave_dev); | 886 | struct net_device *slave_dev); |
875 | int (*ndo_del_slave)(struct net_device *dev, | 887 | int (*ndo_del_slave)(struct net_device *dev, |
876 | struct net_device *slave_dev); | 888 | struct net_device *slave_dev); |
889 | u32 (*ndo_fix_features)(struct net_device *dev, | ||
890 | u32 features); | ||
891 | int (*ndo_set_features)(struct net_device *dev, | ||
892 | u32 features); | ||
877 | }; | 893 | }; |
878 | 894 | ||
879 | /* | 895 | /* |
@@ -925,12 +941,18 @@ struct net_device { | |||
925 | struct list_head napi_list; | 941 | struct list_head napi_list; |
926 | struct list_head unreg_list; | 942 | struct list_head unreg_list; |
927 | 943 | ||
928 | /* Net device features */ | 944 | /* currently active device features */ |
929 | u32 features; | 945 | u32 features; |
930 | 946 | /* user-changeable features */ | |
947 | u32 hw_features; | ||
948 | /* user-requested features */ | ||
949 | u32 wanted_features; | ||
931 | /* VLAN feature mask */ | 950 | /* VLAN feature mask */ |
932 | u32 vlan_features; | 951 | u32 vlan_features; |
933 | 952 | ||
953 | /* Net device feature bits; if you change something, | ||
954 | * also update netdev_features_strings[] in ethtool.c */ | ||
955 | |||
934 | #define NETIF_F_SG 1 /* Scatter/gather IO. */ | 956 | #define NETIF_F_SG 1 /* Scatter/gather IO. */ |
935 | #define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */ | 957 | #define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */ |
936 | #define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */ | 958 | #define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */ |
@@ -966,6 +988,12 @@ struct net_device { | |||
966 | #define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT) | 988 | #define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT) |
967 | #define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) | 989 | #define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) |
968 | 990 | ||
991 | /* Features valid for ethtool to change */ | ||
992 | /* = all defined minus driver/device-class-related */ | ||
993 | #define NETIF_F_NEVER_CHANGE (NETIF_F_HIGHDMA | NETIF_F_VLAN_CHALLENGED | \ | ||
994 | NETIF_F_LLTX | NETIF_F_NETNS_LOCAL) | ||
995 | #define NETIF_F_ETHTOOL_BITS (0x1f3fffff & ~NETIF_F_NEVER_CHANGE) | ||
996 | |||
969 | /* List of features with software fallbacks. */ | 997 | /* List of features with software fallbacks. */ |
970 | #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ | 998 | #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ |
971 | NETIF_F_TSO6 | NETIF_F_UFO) | 999 | NETIF_F_TSO6 | NETIF_F_UFO) |
@@ -2428,8 +2456,13 @@ extern char *netdev_drivername(const struct net_device *dev, char *buffer, int l | |||
2428 | 2456 | ||
2429 | extern void linkwatch_run_queue(void); | 2457 | extern void linkwatch_run_queue(void); |
2430 | 2458 | ||
2459 | static inline u32 netdev_get_wanted_features(struct net_device *dev) | ||
2460 | { | ||
2461 | return (dev->features & ~dev->hw_features) | dev->wanted_features; | ||
2462 | } | ||
2431 | u32 netdev_increment_features(u32 all, u32 one, u32 mask); | 2463 | u32 netdev_increment_features(u32 all, u32 one, u32 mask); |
2432 | u32 netdev_fix_features(struct net_device *dev, u32 features); | 2464 | u32 netdev_fix_features(struct net_device *dev, u32 features); |
2465 | void netdev_update_features(struct net_device *dev); | ||
2433 | 2466 | ||
2434 | void netif_stacked_transfer_operstate(const struct net_device *rootdev, | 2467 | void netif_stacked_transfer_operstate(const struct net_device *rootdev, |
2435 | struct net_device *dev); | 2468 | struct net_device *dev); |