30 Mar, 2020

12 commits

  • Implement TSINFO_GET request to get timestamping information for a network
    device. This is traditionally available via ETHTOOL_GET_TS_INFO ioctl
    request.

    Move part of ethtool_get_ts_info() into common.c so that ioctl and netlink
    code use the same logic to get timestamping information from the device.

    v3: use "TSINFO" rather than "TIMESTAMP", suggested by Richard Cochran

    Signed-off-by: Michal Kubecek
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Add three string sets related to timestamping information:

    ETH_SS_SOF_TIMESTAMPING: SOF_TIMESTAMPING_* flags
    ETH_SS_TS_TX_TYPES: timestamping Tx types
    ETH_SS_TS_RX_FILTERS: timestamping Rx filters

    These will be used for TIMESTAMP_GET request.

    v2: avoid compiler warning ("enumeration value not handled in switch")
    in net_hwtstamp_validate()

    v3: omit dash in Tx type names ("one-step-*" -> "onestep-*"), suggested by
    Richard Cochran

    Signed-off-by: Michal Kubecek
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_EEE_NTF notification whenever EEE settings of a network
    device are modified using ETHTOOL_MSG_EEE_SET netlink message or
    ETHTOOL_SEEE ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement EEE_SET netlink request to set EEE settings of a network device.
    These are traditionally set with ETHTOOL_SEEE ioctl request.

    The netlink interface allows setting the EEE status for all link modes
    supported by kernel but only first 32 link modes can be set at the moment
    as only those are supported by the ethtool_ops callback.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement EEE_GET request to get EEE settings of a network device. These
    are traditionally available via ETHTOOL_GEEE ioctl request.

    The netlink interface allows reporting EEE status for all link modes
    supported by kernel but only first 32 link modes are provided at the moment
    as only those are reported by the ethtool_ops callback and drivers.

    v2: fix alignment (whitespace only)

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_PAUSE_NTF notification whenever pause parameters of
    a network device are modified using ETHTOOL_MSG_PAUSE_SET netlink message
    or ETHTOOL_SPAUSEPARAM ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement PAUSE_SET netlink request to set pause parameters of a network
    device. Thease are traditionally set with ETHTOOL_SPAUSEPARAM ioctl
    request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement PAUSE_GET request to get pause parameters of a network device.
    These are traditionally available via ETHTOOL_GPAUSEPARAM ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_COALESCE_NTF notification whenever coalescing parameters
    of a network device are modified using ETHTOOL_MSG_COALESCE_SET netlink
    message or ETHTOOL_SCOALESCE ioctl request.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement COALESCE_SET netlink request to set coalescing parameters of
    a network device. These are traditionally set with ETHTOOL_SCOALESCE ioctl
    request. This commit adds only support for device coalescing parameters,
    not per queue coalescing parameters.

    Like the ioctl implementation, the generic ethtool code checks if only
    supported parameters are modified; if not, first offending attribute is
    reported using extack.

    v2: fix alignment (whitespace only)

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement COALESCE_GET request to get coalescing parameters of a network
    device. These are traditionally available via ETHTOOL_GCOALESCE ioctl
    request. This commit adds only support for device coalescing parameters,
    not per queue coalescing parameters.

    Omit attributes with zero values unless they are declared as supported
    (i.e. the corresponding bit in ethtool_ops::supported_coalesce_params is
    set).

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Andrew noticed that some handlers for *_SET commands leak a netdev
    reference if required ethtool_ops callbacks do not exist. One of them is
    ethnl_set_privflags(), a simple reproducer would be e.g.

    ip link add veth1 type veth peer name veth2
    ethtool --set-priv-flags veth1 foo on
    ip link del veth1

    Make sure dev_put() is called when ethtool_ops check fails.

    Fixes: f265d799596a ("ethtool: set device private flags with PRIVFLAGS_SET request")
    Reported-by: Andrew Lunn
    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     

27 Mar, 2020

1 commit

  • This patch introduce a new netdev feature, which will be used by drivers
    to state they can perform MACsec transformations in hardware.

    The patchset was gathered by Mark, macsec functinality itself
    was implemented by Dmitry, Mark and Pavel Belous.

    Signed-off-by: Antoine Tenart
    Signed-off-by: Mark Starovoytov
    Signed-off-by: Igor Russkikh
    Signed-off-by: David S. Miller

    Antoine Tenart
     

26 Mar, 2020

1 commit


25 Mar, 2020

1 commit

  • Currently, ethtool feature mask for checksum command is ORed with
    NETIF_F_FCOE_CRC_BIT, which is bit's position number, instead of the
    actual feature bit - NETIF_F_FCOE_CRC.

    The invalid bitmask here might affect unrelated features when toggling
    TX checksumming. For example, TX checksumming is always mistakenly
    reported as enabled on the netdevs tested (mlx5, virtio_net).

    Fixes: f70bb06563ed ("ethtool: update mapping of features to legacy ioctl requests")
    Signed-off-by: Vladyslav Tarasiuk
    Reviewed-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Vladyslav Tarasiuk
     

24 Mar, 2020

1 commit

  • Andrew noticed that some handlers for *_SET commands leak a netdev
    reference if required ethtool_ops callbacks do not exist. A simple
    reproducer would be e.g.

    ip link add veth1 type veth peer name veth2
    ethtool -s veth1 wol g
    ip link del veth1

    Make sure dev_put() is called when ethtool_ops check fails.

    v2: add Fixes tags

    Fixes: a53f3d41e4d3 ("ethtool: set link settings with LINKINFO_SET request")
    Fixes: bfbcfe2032e7 ("ethtool: set link modes related data with LINKMODES_SET request")
    Fixes: e54d04e3afea ("ethtool: set message mask with DEBUG_SET request")
    Fixes: 8d425b19b305 ("ethtool: set wake-on-lan settings with WOL_SET request")
    Reported-by: Andrew Lunn
    Signed-off-by: Michal Kubecek
    Reviewed-by: Andrew Lunn
    Reviewed-by: Florian Fainelli
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     

18 Mar, 2020

1 commit

  • Now that all in-tree drivers have been updated we can
    make the supported_coalesce_params mandatory.

    To save debugging time in case some driver was missed
    (or is out of tree) add a warning when netdev is registered
    with set_coalesce but without supported_coalesce_params.

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

16 Mar, 2020

1 commit

  • As pointed out by Jakub Kicinski, we ethtool netlink code should respond
    with an error if request head has flags set which are not recognized by
    kernel, either as a mistake or because it expects functionality introduced
    in later kernel versions.

    To avoid unnecessary roundtrips, use extack cookie to provide the
    information about supported request flags.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     

14 Mar, 2020

1 commit


13 Mar, 2020

15 commits

  • Send ETHTOOL_MSG_CHANNELS_NTF notification whenever channel counts of
    a network device are modified using ETHTOOL_MSG_CHANNELS_SET netlink
    message or ETHTOOL_SCHANNELS ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement CHANNELS_SET netlink request to set channel counts of a network
    device. These are traditionally set with ETHTOOL_SCHANNELS ioctl request.

    Like the ioctl implementation, the generic ethtool code checks if supplied
    values do not exceed driver defined limits; if they do, first offending
    attribute is reported using extack. Checks preventing removing channels
    used for RX indirection table or zerocopy AF_XDP socket are also
    implemented.

    Move ethtool_get_max_rxfh_channel() helper into common.c so that it can be
    used by both ioctl and netlink code.

    v2:
    - fix netdev reference leak in error path (found by Jakub Kicinsky)

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement CHANNELS_GET request to get channel counts of a network device.
    These are traditionally available via ETHTOOL_GCHANNELS ioctl request.

    Omit attributes for channel types which are not supported by driver or
    device (zero reported for maximum).

    v2: (all suggested by Jakub Kicinski)
    - minor cleanup in channels_prepare_data()
    - more descriptive channels_reply_size()
    - omit attributes with zero max count

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_RINGS_NTF notification whenever ring sizes of a network
    device are modified using ETHTOOL_MSG_RINGS_SET netlink message or
    ETHTOOL_SRINGPARAM ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement RINGS_SET netlink request to set ring sizes of a network device.
    These are traditionally set with ETHTOOL_SRINGPARAM ioctl request.

    Like the ioctl implementation, the generic ethtool code checks if supplied
    values do not exceed driver defined limits; if they do, first offending
    attribute is reported using extack.

    v2:
    - fix netdev reference leak in error path (found by Jakub Kicinsky)

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement RINGS_GET request to get ring sizes of a network device. These
    are traditionally available via ETHTOOL_GRINGPARAM ioctl request.

    Omit attributes for ring types which are not supported by driver or device
    (zero reported for maximum).

    v2: (all suggested by Jakub Kicinski)
    - minor cleanup in rings_prepare_data()
    - more descriptive rings_reply_size()
    - omit attributes with zero max size

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_PRIVFLAGS_NTF notification whenever private flags of
    a network device are modified using ETHTOOL_MSG_PRIVFLAGS_SET netlink
    message or ETHTOOL_SPFLAGS ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement PRIVFLAGS_SET netlink request to set private flags of a network
    device. These are traditionally set with ETHTOOL_SPFLAGS ioctl request.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement PRIVFLAGS_GET request to get private flags for a network device.
    These are traditionally available via ETHTOOL_GPFLAGS ioctl request.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_FEATURES_NTF notification whenever network device features
    are modified using ETHTOOL_MSG_FEATURES_SET netlink message, ethtool ioctl
    request or any other way resulting in call to netdev_update_features() or
    netdev_change_features()

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement FEATURES_SET netlink request to set network device features.
    These are traditionally set using ETHTOOL_SFEATURES ioctl request.

    Actual change is subject to netdev_change_features() sanity checks so that
    it can differ from what was requested. Unlike with most other SET requests,
    in addition to error code and optional extack, kernel provides an optional
    reply message (ETHTOOL_MSG_FEATURES_SET_REPLY) in the same format but with
    different semantics: information about difference between user request and
    actual result and difference between old and new state of dev->features.
    This reply message can be suppressed by setting ETHTOOL_FLAG_OMIT_REPLY
    flag in request header.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Unlike other SET type commands, modifying netdev features is required to
    provide a reply telling userspace what was actually changed, compared to
    what was requested. For that purpose, the "modified" flag provided by
    ethnl_update_bitset() is not sufficient, we need full information which
    bits were requested to change.

    Therefore provide ethnl_parse_bitset() returning effective value and mask
    bitmaps equivalent to the contents of a bitset nested attribute.

    v2: use non-atomic __set_bit() (suggested by David Miller)

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement FEATURES_GET request to get network device features. These are
    traditionally available via ETHTOOL_GFEATURES ioctl request.

    v2:
    - style cleanup suggested by Jakub Kicinski

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Legacy ioctl request like ETHTOOL_GTXCSUM are still used by ethtool utility
    to get values of legacy flags (which rather work as feature groups). These
    are calculated from values of actual features and request to set them is
    implemented as an attempt to set all features mapping to them but there are
    two inconsistencies:

    - tx-checksum-fcoe-crc is shown under tx-checksumming but NETIF_F_FCOE_CRC
    is not included in ETHTOOL_GTXCSUM/ETHTOOL_STXCSUM
    - tx-scatter-gather-fraglist is shown under scatter-gather but
    NETIF_F_FRAGLIST is not included in ETHTOOL_GSG/ETHTOOL_SSG

    As the mapping in ethtool output is more correct from logical point of
    view, fix ethtool_get_feature_mask() to match it.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Andrew Lunn pointed out that even if it's documented that
    ethnl_parse_header() takes reference to network device if it fills it
    into the target structure, its name doesn't make it apparent so that
    corresponding dev_put() looks like mismatched.

    Rename the function ethnl_parse_header_dev_get() to indicate that it
    takes a reference.

    Suggested-by: Andrew Lunn
    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     

06 Mar, 2020

1 commit

  • Linux supports 22 different interrupt coalescing parameters.
    No driver implements them all. Some drivers just ignore the
    ones they don't support, while others have to carry a long
    list of checks to reject unsupported settings.

    To simplify the drivers add the ability to specify inside
    ethtool_ops which parameters are supported and let the core
    reject attempts to set any other one.

    This commit makes the mechanism an opt-in, only drivers which
    set ethtool_opts->coalesce_types to a non-zero value will have
    the checks enforced.

    The same mask is used for global and per queue settings.

    v3: - move the (temporary) check if driver defines types
    earlier (Michal)
    - rename used_types -> nonzero_params, and
    coalesce_types -> supported_coalesce_params (Alex)
    - use EOPNOTSUPP instead of EINVAL (Andrew, Michal)

    Leaving the long series of ifs for now, it seems nice to
    be able to grep for the field and flag names. This will
    probably have to be revisited once netlink support lands.

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Jacob Keller
    Reviewed-by: Michal Kubecek
    Reviewed-by: Andrew Lunn
    Reviewed-by: Alexander Duyck
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

01 Mar, 2020

1 commit


28 Feb, 2020

1 commit


27 Feb, 2020

1 commit

  • Syzbot reported that ethnl_compact_sanity_checks() can be tricked into
    reading past the end of ETHTOOL_A_BITSET_VALUE and ETHTOOL_A_BITSET_MASK
    attributes and even the message by passing a value between (u32)(-31)
    and (u32)(-1) as ETHTOOL_A_BITSET_SIZE.

    The problem is that DIV_ROUND_UP(attr_nbits, 32) is 0 for such values so
    that zero length ETHTOOL_A_BITSET_VALUE will pass the length check but
    ethnl_bitmap32_not_zero() check would try to access up to 512 MB of
    attribute "payload".

    Prevent this overflow byt limiting the bitset size. Technically, compact
    bitset format would allow bitset sizes up to almost 2^18 (so that the
    nest size does not exceed U16_MAX) but bitsets used by ethtool are much
    shorter. S16_MAX, the largest value which can be directly used as an
    upper limit in policy, should be a reasonable compromise.

    Fixes: 10b518d4e6dd ("ethtool: netlink bitset handling")
    Reported-by: syzbot+7fd4ed5b4234ab1fdccd@syzkaller.appspotmail.com
    Reported-by: syzbot+709b7a64d57978247e44@syzkaller.appspotmail.com
    Reported-by: syzbot+983cb8fb2d17a7af549d@syzkaller.appspotmail.com
    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     

22 Feb, 2020

1 commit


19 Feb, 2020

1 commit

  • Add support for low latency Reed Solomon FEC as LLRS.

    The LL-FEC is defined by the 25G/50G ethernet consortium,
    in the document titled "Low Latency Reed Solomon Forward Error Correction"

    Signed-off-by: Aya Levin
    Reviewed-by: Eran Ben Elisha
    CC: Andrew Lunn
    Signed-off-by: Saeed Mahameed
    Reviewed-by: Andrew Lunn

    Aya Levin