]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - include/linux/ethtool.h
ethtool: prevent null pointer dereference with NTUPLE set but no set_rx_ntuple
[mirror_ubuntu-bionic-kernel.git] / include / linux / ethtool.h
index aac3e2eeb4fd626565462379c0acd7fb4d1e1c66..c04d1316d221b354e2a7ffac0bb713e55bda0f0d 100644 (file)
@@ -13,6 +13,9 @@
 #ifndef _LINUX_ETHTOOL_H
 #define _LINUX_ETHTOOL_H
 
+#ifdef __KERNEL__
+#include <linux/compat.h>
+#endif
 #include <linux/types.h>
 #include <linux/if_ether.h>
 
@@ -450,6 +453,37 @@ struct ethtool_rxnfc {
        __u32                           rule_locs[0];
 };
 
+#ifdef __KERNEL__
+#ifdef CONFIG_COMPAT
+
+struct compat_ethtool_rx_flow_spec {
+       u32             flow_type;
+       union {
+               struct ethtool_tcpip4_spec              tcp_ip4_spec;
+               struct ethtool_tcpip4_spec              udp_ip4_spec;
+               struct ethtool_tcpip4_spec              sctp_ip4_spec;
+               struct ethtool_ah_espip4_spec           ah_ip4_spec;
+               struct ethtool_ah_espip4_spec           esp_ip4_spec;
+               struct ethtool_usrip4_spec              usr_ip4_spec;
+               struct ethhdr                           ether_spec;
+               u8                                      hdata[72];
+       } h_u, m_u;
+       compat_u64      ring_cookie;
+       u32             location;
+};
+
+struct compat_ethtool_rxnfc {
+       u32                             cmd;
+       u32                             flow_type;
+       compat_u64                      data;
+       struct compat_ethtool_rx_flow_spec fs;
+       u32                             rule_cnt;
+       u32                             rule_locs[0];
+};
+
+#endif /* CONFIG_COMPAT */
+#endif /* __KERNEL__ */
+
 /**
  * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection
  * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR
@@ -614,6 +648,9 @@ enum ethtool_sfeatures_retval_bits {
 
 #include <linux/rculist.h>
 
+/* needed by dev_disable_lro() */
+extern int __ethtool_set_flags(struct net_device *dev, u32 flags);
+
 struct ethtool_rx_ntuple_flow_spec_container {
        struct ethtool_rx_ntuple_flow_spec fs;
        struct list_head list;
@@ -626,6 +663,22 @@ struct ethtool_rx_ntuple_list {
        unsigned int            count;
 };
 
+/**
+ * enum ethtool_phys_id_state - indicator state for physical identification
+ * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
+ * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
+ * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
+ *     is not supported)
+ * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
+ *     is not supported)
+ */
+enum ethtool_phys_id_state {
+       ETHTOOL_ID_INACTIVE,
+       ETHTOOL_ID_ACTIVE,
+       ETHTOOL_ID_ON,
+       ETHTOOL_ID_OFF
+};
+
 struct net_device;
 
 /* Some generic methods drivers may use in their ethtool_ops */
@@ -643,65 +696,129 @@ int ethtool_op_set_ufo(struct net_device *dev, u32 data);
 u32 ethtool_op_get_flags(struct net_device *dev);
 int ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported);
 void ethtool_ntuple_flush(struct net_device *dev);
+bool ethtool_invalid_flags(struct net_device *dev, u32 data, u32 supported);
 
 /**
- * &ethtool_ops - Alter and report network device settings
- * get_settings: Get device-specific settings
- * set_settings: Set device-specific settings
- * get_drvinfo: Report driver information
- * get_regs: Get device registers
- * get_wol: Report whether Wake-on-Lan is enabled
- * set_wol: Turn Wake-on-Lan on or off
- * get_msglevel: Report driver message level
- * set_msglevel: Set driver message level
- * nway_reset: Restart autonegotiation
- * get_link: Get link status
- * get_eeprom: Read data from the device EEPROM
- * set_eeprom: Write data to the device EEPROM
- * get_coalesce: Get interrupt coalescing parameters
- * set_coalesce: Set interrupt coalescing parameters
- * get_ringparam: Report ring sizes
- * set_ringparam: Set ring sizes
- * get_pauseparam: Report pause parameters
- * set_pauseparam: Set pause parameters
- * get_rx_csum: Report whether receive checksums are turned on or off
- * set_rx_csum: Turn receive checksum on or off
- * get_tx_csum: Report whether transmit checksums are turned on or off
- * set_tx_csum: Turn transmit checksums on or off
- * get_sg: Report whether scatter-gather is enabled
- * set_sg: Turn scatter-gather on or off
- * get_tso: Report whether TCP segmentation offload is enabled
- * set_tso: Turn TCP segmentation offload on or off
- * get_ufo: Report whether UDP fragmentation offload is enabled
- * set_ufo: Turn UDP fragmentation offload on or off
- * self_test: Run specified self-tests
- * get_strings: Return a set of strings that describe the requested objects
- * phys_id: Identify the device
- * get_stats: Return statistics about the device
- * get_flags: get 32-bit flags bitmap
- * set_flags: set 32-bit flags bitmap
- *
- * Description:
- *
- * get_settings:
- *     @get_settings is passed an &ethtool_cmd to fill in.  It returns
- *     an negative errno or zero.
- *
- * set_settings:
- *     @set_settings is passed an &ethtool_cmd and should attempt to set
- *     all the settings this device supports.  It may return an error value
- *     if something goes wrong (otherwise 0).
- *
- * get_eeprom:
+ * struct ethtool_ops - optional netdev operations
+ * @get_settings: Get various device settings including Ethernet link
+ *     settings.  Returns a negative error code or zero.
+ * @set_settings: Set various device settings including Ethernet link
+ *     settings.  Returns a negative error code or zero.
+ * @get_drvinfo: Report driver/device information.  Should only set the
+ *     @driver, @version, @fw_version and @bus_info fields.  If not
+ *     implemented, the @driver and @bus_info fields will be filled in
+ *     according to the netdev's parent device.
+ * @get_regs_len: Get buffer length required for @get_regs
+ * @get_regs: Get device registers
+ * @get_wol: Report whether Wake-on-Lan is enabled
+ * @set_wol: Turn Wake-on-Lan on or off.  Returns a negative error code
+ *     or zero.
+ * @get_msglevel: Report driver message level.  This should be the value
+ *     of the @msg_enable field used by netif logging functions.
+ * @set_msglevel: Set driver message level
+ * @nway_reset: Restart autonegotiation.  Returns a negative error code
+ *     or zero.
+ * @get_link: Report whether physical link is up.  Will only be called if
+ *     the netdev is up.  Should usually be set to ethtool_op_get_link(),
+ *     which uses netif_carrier_ok().
+ * @get_eeprom: Read data from the device EEPROM.
  *     Should fill in the magic field.  Don't need to check len for zero
  *     or wraparound.  Fill in the data argument with the eeprom values
  *     from offset to offset + len.  Update len to the amount read.
  *     Returns an error or zero.
- *
- * set_eeprom:
+ * @set_eeprom: Write data to the device EEPROM.
  *     Should validate the magic field.  Don't need to check len for zero
  *     or wraparound.  Update len to the amount written.  Returns an error
  *     or zero.
+ * @get_coalesce: Get interrupt coalescing parameters.  Returns a negative
+ *     error code or zero.
+ * @set_coalesce: Set interrupt coalescing parameters.  Returns a negative
+ *     error code or zero.
+ * @get_ringparam: Report ring sizes
+ * @set_ringparam: Set ring sizes.  Returns a negative error code or zero.
+ * @get_pauseparam: Report pause parameters
+ * @set_pauseparam: Set pause parameters.  Returns a negative error code
+ *     or zero.
+ * @get_rx_csum: Deprecated in favour of the netdev feature %NETIF_F_RXCSUM.
+ *     Report whether receive checksums are turned on or off.
+ * @set_rx_csum: Deprecated in favour of generic netdev features.  Turn
+ *     receive checksum on or off.  Returns a negative error code or zero.
+ * @get_tx_csum: Deprecated as redundant. Report whether transmit checksums
+ *     are turned on or off.
+ * @set_tx_csum: Deprecated in favour of generic netdev features.  Turn
+ *     transmit checksums on or off.  Returns a egative error code or zero.
+ * @get_sg: Deprecated as redundant.  Report whether scatter-gather is
+ *     enabled.  
+ * @set_sg: Deprecated in favour of generic netdev features.  Turn
+ *     scatter-gather on or off. Returns a negative error code or zero.
+ * @get_tso: Deprecated as redundant.  Report whether TCP segmentation
+ *     offload is enabled.
+ * @set_tso: Deprecated in favour of generic netdev features.  Turn TCP
+ *     segmentation offload on or off.  Returns a negative error code or zero.
+ * @self_test: Run specified self-tests
+ * @get_strings: Return a set of strings that describe the requested objects
+ * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
+ *     attached to it.  The implementation may update the indicator
+ *     asynchronously or synchronously, but in either case it must return
+ *     quickly.  It is initially called with the argument %ETHTOOL_ID_ACTIVE,
+ *     and must either activate asynchronous updates or return -%EINVAL.
+ *     If it returns -%EINVAL then it will be called again at intervals with
+ *     argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
+ *     the indicator accordingly.  Finally, it is called with the argument
+ *     %ETHTOOL_ID_INACTIVE and must deactivate the indicator.  Returns a
+ *     negative error code or zero.
+ * @phys_id: Deprecated in favour of @set_phys_id.
+ *     Identify the physical device, e.g. by flashing an LED
+ *     attached to it until interrupted by a signal or the given time
+ *     (in seconds) elapses.  If the given time is zero, use a default
+ *     time limit.  Returns a negative error code or zero.  Being
+ *     interrupted by a signal is not an error.
+ * @get_ethtool_stats: Return extended statistics about the device.
+ *     This is only useful if the device maintains statistics not
+ *     included in &struct rtnl_link_stats64.
+ * @begin: Function to be called before any other operation.  Returns a
+ *     negative error code or zero.
+ * @complete: Function to be called after any other operation except
+ *     @begin.  Will be called even if the other operation failed.
+ * @get_ufo: Deprecated as redundant.  Report whether UDP fragmentation
+ *     offload is enabled.
+ * @set_ufo: Deprecated in favour of generic netdev features.  Turn UDP
+ *     fragmentation offload on or off.  Returns a negative error code or zero.
+ * @get_flags: Deprecated as redundant.  Report features included in
+ *     &enum ethtool_flags that are enabled.  
+ * @set_flags: Deprecated in favour of generic netdev features.  Turn
+ *     features included in &enum ethtool_flags on or off.  Returns a
+ *     negative error code or zero.
+ * @get_priv_flags: Report driver-specific feature flags.
+ * @set_priv_flags: Set driver-specific feature flags.  Returns a negative
+ *     error code or zero.
+ * @get_sset_count: Get number of strings that @get_strings will write.
+ * @get_rxnfc: Get RX flow classification rules.  Returns a negative
+ *     error code or zero.
+ * @set_rxnfc: Set RX flow classification rules.  Returns a negative
+ *     error code or zero.
+ * @flash_device: Write a firmware image to device's flash memory.
+ *     Returns a negative error code or zero.
+ * @reset: Reset (part of) the device, as specified by a bitmask of
+ *     flags from &enum ethtool_reset_flags.  Returns a negative
+ *     error code or zero.
+ * @set_rx_ntuple: Set an RX n-tuple rule.  Returns a negative error code
+ *     or zero.
+ * @get_rx_ntuple: Deprecated.
+ * @get_rxfh_indir: Get the contents of the RX flow hash indirection table.
+ *     Returns a negative error code or zero.
+ * @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
+ *     Returns a negative error code or zero.
+ *
+ * All operations are optional (i.e. the function pointer may be set
+ * to %NULL) and callers must take this into account.  Callers must
+ * hold the RTNL, except that for @get_drvinfo the caller may or may
+ * not hold the RTNL.
+ *
+ * See the structures used by these operations for further documentation.
+ *
+ * See &struct net_device and &struct net_device_ops for documentation
+ * of the generic netdev features interface.
  */
 struct ethtool_ops {
        int     (*get_settings)(struct net_device *, struct ethtool_cmd *);
@@ -740,6 +857,7 @@ struct ethtool_ops {
        int     (*set_tso)(struct net_device *, u32);
        void    (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
        void    (*get_strings)(struct net_device *, u32 stringset, u8 *);
+       int     (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
        int     (*phys_id)(struct net_device *, u32);
        void    (*get_ethtool_stats)(struct net_device *,
                                     struct ethtool_stats *, u64 *);