Commit Graph

56 Commits

Author SHA1 Message Date
Michal Schmidt 16f31bf20e ethtool: RX software timestamp for all
JIRA: https://issues.redhat.com/browse/RHEL-57751

commit 12d337339d9fd71cf24b337727e51d5b3d52bcef
Author: Gal Pressman <gal@nvidia.com>
Date:   Sun Sep 1 14:27:49 2024 +0300

    ethtool: RX software timestamp for all

    All devices support SOF_TIMESTAMPING_RX_SOFTWARE by virtue of
    net_timestamp_check() being called in the device independent code.

    Move the responsibility of reporting SOF_TIMESTAMPING_RX_SOFTWARE and
    SOF_TIMESTAMPING_SOFTWARE, and setting PHC index to -1 to the core.
    Device drivers no longer need to use them.

    Suggested-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
    Link: https://lore.kernel.org/netdev/661550e348224_23a2b2294f7@willemb.c.googlers.com.notmuch/
    Co-developed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
    Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
    Signed-off-by: Gal Pressman <gal@nvidia.com>
    Reviewed-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Reviewed-by: Willem de Bruijn <willemb@google.com>
    Link: https://patch.msgid.link/20240901112803.212753-2-gal@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-11-05 11:39:23 +01:00
Michal Schmidt 3b0236f68f ethtool: refactor checking max channels
JIRA: https://issues.redhat.com/browse/RHEL-57751

commit 916b7d31f7eef81fe20f86ef52c36938fa971872
Author: Mina Almasry <almasrymina@google.com>
Date:   Thu Aug 8 20:53:45 2024 +0000

    ethtool: refactor checking max channels

    Currently ethtool_set_channel calls separate functions to check whether
    the new channel number violates rss configuration or flow steering
    configuration.

    Very soon we need to check whether the new channel number violates
    memory provider configuration as well.

    To do all 3 checks cleanly, add a wrapper around
    ethtool_get_max_rxnfc_channel() and ethtool_get_max_rxfh_channel(),
    which does both checks. We can later extend this wrapper to add the
    memory provider check in one place.

    Note that in the current code, we put a descriptive genl error message
    when we run into issues. To preserve the error message, we pass the
    genl_info* to the common helper. The ioctl calls can pass NULL instead.

    Suggested-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Mina Almasry <almasrymina@google.com>
    Link: https://patch.msgid.link/20240808205345.2141858-1-almasrymina@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-11-04 19:42:47 +01:00
Michal Schmidt e1c08d6bdf net: ethtool: check rxfh_max_num_contexts != 1 at register time
JIRA: https://issues.redhat.com/browse/RHEL-57751

commit ceb627435b00fe3bcee5957aeb3e5282a1f06eb6
Author: Edward Cree <ecree.xilinx@gmail.com>
Date:   Wed Aug 7 17:06:13 2024 +0100

    net: ethtool: check rxfh_max_num_contexts != 1 at register time

    A value of 1 doesn't make sense, as it implies the only allowed
     context ID is 0, which is reserved for the default context - in
     which case the driver should just not claim to support custom
     RSS contexts at all.

    Suggested-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
    Link: https://lore.kernel.org/c07725b3a3d0b0a63b85e230f9c77af59d4d07f8.1723045898.git.ecree.xilinx@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-11-04 19:42:46 +01:00
Rado Vrbovsky f177edd8c5 Merge: CNB96: netdev_features: start cleaning netdev_features_t up
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5362

JIRA: https://issues.redhat.com/browse/RHEL-59091

Explanation from the upstream cover letter by Alexander Lobakin:

> NETDEV_FEATURE_COUNT is currently 64, which means we can't add any new
> features as netdev_features_t is u64.
> As per several discussions, instead of converting netdev_features_t to
> a bitmap, which would mean A LOT of changes, we can try cleaning up
> netdev feature bits.
> There's a bunch of bits which don't really mean features, rather device
> attributes/properties that can't be changed via Ethtool in any of the
> drivers. Such attributes can be moved to netdev private flags without
> losing any functionality.
> 
> Start converting some read-only netdev features to private flags from
> the ones that are most obvious, like lockless Tx, inability to change
> network namespace etc. I was able to reduce NETDEV_FEATURE_COUNT from
> 64 to 60, which mean 4 free slots for new features. There are obviously
> more read-only features to convert, such as highDMA, "challenged VLAN",
> HSR (4 bits) - this will be done in subsequent series.
> Please note that netdev features are not uAPI/ABI by any means. Ethtool
> passes their names and bits to the userspace separately and there are no
> hardcoded names/bits in the userspace, so that new Ethtool could work
> on older kernels and vice versa. Even shell scripts won't most likely
> break since the removed bits were always read-only, meaning nobody would
> try touching them from a script.

I proposed a Release Note Text in the Jira to document that "tx-lockless", "netns-local", "fcoe-mtu" will no longer appear in "ethtool -k". 

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>

Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com>
Approved-by: Ivan Vecera <ivecera@redhat.com>
Approved-by: Antoine Tenart <atenart@redhat.com>
Approved-by: Eric Chanudet <echanude@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2024-10-20 09:09:03 +00:00
Michal Schmidt 6dfb2f2844 netdev_features: convert NETIF_F_FCOE_MTU to dev->fcoe_mtu
JIRA: https://issues.redhat.com/browse/RHEL-59091

commit 782dbbf589cd9082effaec522e3f1b4ce1594803
Author: Alexander Lobakin <aleksander.lobakin@intel.com>
Date:   Thu Aug 29 14:33:39 2024 +0200

    netdev_features: convert NETIF_F_FCOE_MTU to dev->fcoe_mtu

    Ability to handle maximum FCoE frames of 2158 bytes can never be changed
    and thus more of an attribute, not a toggleable feature.
    Move it from netdev_features_t to "cold" priv flags (bitfield bool) and
    free yet another feature bit.

    Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-03 18:00:01 +02:00
Michal Schmidt a672f9b810 netdev_features: convert NETIF_F_NETNS_LOCAL to dev->netns_local
JIRA: https://issues.redhat.com/browse/RHEL-59091

commit 05c1280a2bcfca187fe7fa90bb240602cf54af0a
Author: Alexander Lobakin <aleksander.lobakin@intel.com>
Date:   Thu Aug 29 14:33:38 2024 +0200

    netdev_features: convert NETIF_F_NETNS_LOCAL to dev->netns_local

    "Interface can't change network namespaces" is rather an attribute,
    not a feature, and it can't be changed via Ethtool.
    Make it a "cold" private flag instead of a netdev_feature and free
    one more bit.

    Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Conflicts:
	drivers/net/amt.c
	drivers/net/ethernet/adi/adin1110.c

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-03 17:59:51 +02:00
Michal Schmidt 555cb3d84d netdev_features: convert NETIF_F_LLTX to dev->lltx
JIRA: https://issues.redhat.com/browse/RHEL-59091

commit 00d066a4d4edbe559ba6c35153da71d4b2b8a383
Author: Alexander Lobakin <aleksander.lobakin@intel.com>
Date:   Thu Aug 29 14:33:37 2024 +0200

    netdev_features: convert NETIF_F_LLTX to dev->lltx

    NETIF_F_LLTX can't be changed via Ethtool and is not a feature,
    rather an attribute, very similar to IFF_NO_QUEUE (and hot).
    Free one netdev_features_t bit and make it a "hot" private flag.

    Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Conflicts:
	drivers/net/macsec.c
	drivers/net/veth.c
	net/ipv6/ip6_tunnel.c
	- Context.

	drivers/net/amt.c
	drivers/net/netkit.c
	- Non-existent in RHEL 9.

	drivers/net/ethernet/chelsio/cxgb/cxgb2.c
	drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
	- Drivers disabled in RHEL 9. Skipped.

	net/dsa/user.c
	- This is slave.c in RHEL 9, but CONFIG_NET_DSA is disabled,
	  so skipped the hunk.

	net/core/net-sysfs.c
	- Code not present because of missing commit 74293ea1c4db
	  ("net: sysfs: Do not create sysfs for non BQL device")

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-03 17:59:44 +02:00
Michal Schmidt 7052eaa805 net: Add struct kernel_ethtool_ts_info
JIRA: https://issues.redhat.com/browse/RHEL-57750

commit 2111375b85ad173d58e7b8604246a3de60950ac8
Author: Kory Maincent <kory.maincent@bootlin.com>
Date:   Tue Jul 9 15:53:38 2024 +0200

    net: Add struct kernel_ethtool_ts_info

    In prevision to add new UAPI for hwtstamp we will be limited to the struct
    ethtool_ts_info that is currently passed in fixed binary format through the
    ETHTOOL_GET_TS_INFO ethtool ioctl. It would be good if new kernel code
    already started operating on an extensible kernel variant of that
    structure, similar in concept to struct kernel_hwtstamp_config vs struct
    hwtstamp_config.

    Since struct ethtool_ts_info is in include/uapi/linux/ethtool.h, here
    we introduce the kernel-only structure in include/linux/ethtool.h.
    The manual copy is then made in the function called by ETHTOOL_GET_TS_INFO.

    Acked-by: Shannon Nelson <shannon.nelson@amd.com>
    Acked-by: Alexandra Winter <wintera@linux.ibm.com>
    Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
    Link: https://patch.msgid.link/20240709-feature_ptp_netnext-v17-6-b5317f50df2a@bootlin.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Conflicts:
	drivers/net/dsa/microchip/ksz_ptp.c
	drivers/net/dsa/microchip/ksz_ptp.h
	drivers/net/ethernet/engleder/tsnep_ethtool.c
	drivers/net/ethernet/fungible/funeth/funeth_ethtool.c
	drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c
	drivers/net/ethernet/renesas/rtsn.c
	net/dsa/user.c
	- code not present in RHEL

	drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c
	drivers/net/ethernet/mscc/ocelot_ptp.c
	- code disabled in RHEL config

	drivers/net/ethernet/hisilicon/hns3/hnae3.h
	drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
	drivers/net/ethernet/sfc/ptp.h
	- context conflicts due to patching out-of-order

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-01 12:19:15 +02:00
Michal Schmidt dc450f6872 net: Change the API of PHY default timestamp to MAC
JIRA: https://issues.redhat.com/browse/RHEL-57750

commit 2dd35600590148d843367c04975acad3c1a527c3
Author: Kory Maincent <kory.maincent@bootlin.com>
Date:   Tue Jul 9 15:53:36 2024 +0200

    net: Change the API of PHY default timestamp to MAC

    Change the API to select MAC default time stamping instead of the PHY.
    Indeed the PHY is closer to the wire therefore theoretically it has less
    delay than the MAC timestamping but the reality is different. Due to lower
    time stamping clock frequency, latency in the MDIO bus and no PHC hardware
    synchronization between different PHY, the PHY PTP is often less precise
    than the MAC. The exception is for PHY designed specially for PTP case but
    these devices are not very widespread. For not breaking the compatibility
    default_timestamp flag has been introduced in phy_device that is set by
    the phy driver to know we are using the old API behavior.

    Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
    Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
    Link: https://patch.msgid.link/20240709-feature_ptp_netnext-v17-4-b5317f50df2a@bootlin.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-01 12:19:15 +02:00
Michal Schmidt e8ead8fcca net: phy: bcm54811: New link mode for BroadR-Reach
JIRA: https://issues.redhat.com/browse/RHEL-57750

commit 2c1583290b08c5aa9005178a573be8f329de2976
Author: Kamil Horák (2N) <kamilh@axis.com>
Date:   Fri Jul 12 17:07:06 2024 +0200

    net: phy: bcm54811: New link mode for BroadR-Reach

    Introduce a new link mode necessary for 10 MBit single-pair
    connection in BroadR-Reach mode on bcm5481x PHY by Broadcom.
    This new link mode, 10baseT1BRR, is known as 1BR10 in the Broadcom
    terminology. Another link mode to be used is 1BR100 and it is already
    present as 100baseT1, because Broadcom's 1BR100 became 100baseT1
    (IEEE 802.3bw).

    Signed-off-by: Kamil Horák (2N) <kamilh@axis.com>
    Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Link: https://patch.msgid.link/20240712150709.3134474-2-kamilh@axis.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-01 12:19:15 +02:00
Michal Schmidt 1813595b28 net: ethtool: let drivers remove lost RSS contexts
JIRA: https://issues.redhat.com/browse/RHEL-57750

commit d69ba6bbaf1f606ac354e925571a54d025e32aae
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Thu Jul 11 15:07:03 2024 -0700

    net: ethtool: let drivers remove lost RSS contexts

    RSS contexts may get lost from a device, in various extreme circumstances.
    Specifically if the firmware leaks resources and resets, or crashes and
    either recovers in partially working state or the crash causes a
    different FW version to run - creating the context again may fail.

    Drivers should do their absolute best to prevent this from happening.
    When it does, however, telling user that a context exists, when it can't
    possibly be used any more is counter productive. Add a helper for
    drivers to discard contexts. Print an error, in the future netlink
    notification will also be sent.

    More robust approaches were proposed, like keeping the contexts
    but marking them as "dead" (but possibly resurrected by next reset).
    That may be better but it's unclear at this stage whether the
    effort is worth the benefits.

    Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
    Link: https://patch.msgid.link/20240711220713.283778-2-kuba@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-01 12:19:15 +02:00
Michal Schmidt a29417ea2f ethtool: use the rss context XArray in ring deactivation safety-check
JIRA: https://issues.redhat.com/browse/RHEL-57750

commit 24ac7e5440815bb03bdfa9bc7e43a412b050dbaa
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Wed Jul 10 10:40:43 2024 -0700

    ethtool: use the rss context XArray in ring deactivation safety-check

    ethtool_get_max_rxfh_channel() gets called when user requests
    deactivating Rx channels. Check the additional RSS contexts, too.

    While we do track whether RSS context has an indirection
    table explicitly set by the user, no driver looks at that bit.
    Assume drivers won't auto-regenerate the additional tables,
    to be safe.

    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Link: https://patch.msgid.link/20240710174043.754664-3-kuba@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-01 12:19:14 +02:00
Michal Schmidt 4fc555c2b7 ethtool: fail closed if we can't get max channel used in indirection tables
JIRA: https://issues.redhat.com/browse/RHEL-57750

commit 2899d58462ba868287d6ff3acad3675e7adf934f
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Wed Jul 10 10:40:42 2024 -0700

    ethtool: fail closed if we can't get max channel used in indirection tables

    Commit 0d1b7d6c9274 ("bnxt: fix crashes when reducing ring count with
    active RSS contexts") proves that allowing indirection table to contain
    channels with out of bounds IDs may lead to crashes. Currently the
    max channel check in the core gets skipped if driver can't fetch
    the indirection table or when we can't allocate memory.

    Both of those conditions should be extremely rare but if they do
    happen we should try to be safe and fail the channel change.

    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Link: https://patch.msgid.link/20240710174043.754664-2-kuba@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-01 12:19:14 +02:00
Michal Schmidt 5055bf8b4c ethtool: remove ethtool_eee_use_linkmodes
JIRA: https://issues.redhat.com/browse/RHEL-57750

commit d7933a2c7f87667a87a2c0d0c5a1617c414c6024
Author: Heiner Kallweit <hkallweit1@gmail.com>
Date:   Tue Mar 5 22:26:10 2024 +0100

    ethtool: remove ethtool_eee_use_linkmodes

    After 292fac464b01 ("net: ethtool: eee: Remove legacy _u32 from keee")
    this function has no user any longer.

    Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Link: https://lore.kernel.org/r/b4ff9b51-092b-4d44-bfce-c95342a05b51@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-01 08:41:12 +02:00
Lucas Zampieri 4aba3f45f9 Merge: CNB95: ethtool: update ethtool core to upstream v6.8
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4236

JIRA: https://issues.redhat.com/browse/RHEL-36217  

Commits:
```
b534dc46c8ae ("net_tstamp: add SOF_TIMESTAMPING_OPT_ID_TCP")
70f7457ad6d6 ("net: create device lookup API with reference tracking")
3515440df461 ("ipv6: also use netdev_hold() in ip6_route_check_nh()")
108a36d07c01 ("ethtool: Fix mod state of verbose no_mask bitset")
524515020f25 ("Revert "ethtool: Fix mod state of verbose no_mask bitset"")
f55d8e60f109 ("net: ethtool: Fix documentation of ethtool_sprintf()")
65c9fde15a65 ("net: vlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set()")
0bca3f7f9acd ("net: macvlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set()")
c0dabeb4c666 ("net: bonding: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set()")
ef5eb9c5ce45 ("net: fec: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()")
547b006d1922 ("net: fec: delete fec_ptp_disable_hwts()")
fd770e856e22 ("net: remove phy_has_hwtstamp() -> phy_mii_ioctl() decision from converted drivers")
c35e927cbe09 ("net: omit ndo_hwtstamp_get() call when possible in dev_set_hwtstamp_phylib()")
446e2305827b ("net: Convert PHYs hwtstamp callback to use kernel_hwtstamp_config")
430dc3256d57 ("net: phy: Remove the call to phy_mii_ioctl in phy_hwstamp_get/set")
b8768dc40777 ("net: ethtool: Refactor identical get_ts_info implementations.")
202cb220026e ("net: macb: Convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()")
011dd3b3f83f ("net: Make dev_set_hwtstamp_phylib accessible")
915d25a9d69b ("net: phy: micrel: fix ts_info value in case of no phc")
acec05fb78ab ("net_tstamp: Add TIMESTAMPING SOFTWARE and HARDWARE mask")
11d55be06df0 ("net: ethtool: Add a command to expose current time stamping layer")
d905f9c75329 ("net: ethtool: Add a command to list available time stamping layers")
51bdf3165f01 ("net: Replace hwtstamp_source by timestamping layer")
0f7f463d4821 ("net: Change the API of PHY default timestamp to MAC")
091fab122869 ("net: ethtool: ts: Update GET_TS to reply the current selected timestamp")
152c75e1d002 ("net: ethtool: ts: Let the active time stamping layer be selectable")
289354f21b2c ("net: partial revert of the "Make timestamping selectable: series")
cc124ad39288 ("Documentation: networking: add missing PLCA messages from the message list")
d0c3891db2d2 ("ethtool: reformat kerneldoc for struct ethtool_link_settings")
1271ca00aa7f ("ethtool: reformat kerneldoc for struct ethtool_fec_stats")
f1172f3ee3a9 ("ethtool: netlink: Add missing ethnl_ops_begin/complete")
```

Signed-off-by: Ivan Vecera <ivecera@redhat.com>

Approved-by: Davide Caratti <dcaratti@redhat.com>
Approved-by: Antoine Tenart <atenart@redhat.com>
Approved-by: Michal Schmidt <mschmidt@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: Lucas Zampieri <lzampier@redhat.com>
2024-06-06 19:18:41 +00:00
Lucas Zampieri 4cee9a6671 Merge: CNB95: ethtool: switch EEE netlink interface to use EEE linkmode bitmaps
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4136

JIRA: https://issues.redhat.com/browse/RHEL-32101  

Commits:
```
d80a52335374 ("ethtool: replace struct ethtool_eee with a new struct ethtool_keee on kernel side")
0b3100bc8fa7 ("ethtool: switch back from ethtool_keee to ethtool_eee for ioctl")
285cc15cc555 ("ethtool: adjust struct ethtool_keee to kernel needs")
1d756ff13da6 ("ethtool: add suffix _u32 to legacy bitmap members of struct ethtool_keee")
1f069de63602 ("ethtool: add linkmode bitmap support to struct ethtool_keee")
```

Signed-off-by: Ivan Vecera <ivecera@redhat.com>

Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com>
Approved-by: Michal Schmidt <mschmidt@redhat.com>
Approved-by: Petr Oros <poros@redhat.com>
Approved-by: Davide Caratti <dcaratti@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: Lucas Zampieri <lzampier@redhat.com>
2024-06-03 19:56:02 +00:00
Ivan Vecera b128d4b635 net: partial revert of the "Make timestamping selectable: series
JIRA: https://issues.redhat.com/browse/RHEL-36217

Conflicts:
- hunk for lan966x removed as it does not exist in RHEL
- context conflict caused by presence of RH_KABI macros

commit 289354f21b2c3fac93e956efd45f256a88a4d997
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Sat Nov 18 18:38:05 2023 -0800

    net: partial revert of the "Make timestamping selectable: series

    Revert following commits:

    commit acec05fb78ab ("net_tstamp: Add TIMESTAMPING SOFTWARE and HARDWARE mask")
    commit 11d55be06df0 ("net: ethtool: Add a command to expose current time stamping layer")
    commit bb8645b00ced ("netlink: specs: Introduce new netlink command to get current timestamp")
    commit d905f9c75329 ("net: ethtool: Add a command to list available time stamping layers")
    commit aed5004ee7a0 ("netlink: specs: Introduce new netlink command to list available time stamping layers")
    commit 51bdf3165f01 ("net: Replace hwtstamp_source by timestamping layer")
    commit 0f7f463d4821 ("net: Change the API of PHY default timestamp to MAC")
    commit 091fab122869 ("net: ethtool: ts: Update GET_TS to reply the current selected timestamp")
    commit 152c75e1d002 ("net: ethtool: ts: Let the active time stamping layer be selectable")
    commit ee60ea6be0d3 ("netlink: specs: Introduce time stamping set command")

    They need more time for reviews.

    Link: https://lore.kernel.org/all/20231118183529.6e67100c@kernel.org/
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-05-16 18:34:23 +02:00
Ivan Vecera 5a1bdf9297 net: Change the API of PHY default timestamp to MAC
JIRA: https://issues.redhat.com/browse/RHEL-36217

Conflicts:
- context conflict caused by presence of RH_KABI macros

commit 0f7f463d4821a4f52fa5c0a961389e651d50c384
Author: Kory Maincent <kory.maincent@bootlin.com>
Date:   Tue Nov 14 12:28:41 2023 +0100

    net: Change the API of PHY default timestamp to MAC

    Change the API to select MAC default time stamping instead of the PHY.
    Indeed the PHY is closer to the wire therefore theoretically it has less
    delay than the MAC timestamping but the reality is different. Due to lower
    time stamping clock frequency, latency in the MDIO bus and no PHC hardware
    synchronization between different PHY, the PHY PTP is often less precise
    than the MAC. The exception is for PHY designed specially for PTP case but
    these devices are not very widespread. For not breaking the compatibility I
    introduce a default_timestamp flag in phy_device that is set by the phy
    driver to know we are using the old API behavior.

    The phy_set_timestamp function is called at each call of phy_attach_direct.
    In case of MAC driver using phylink this function is called when the
    interface is turned up. Then if the interface goes down and up again the
    last choice of timestamp will be overwritten by the default choice.
    A solution could be to cache the timestamp status but it can bring other
    issues. In case of SFP, if we change the module, it doesn't make sense to
    blindly re-set the timestamp back to PHY, if the new module has a PHY with
    mediocre timestamping capabilities.

    Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-05-16 18:34:23 +02:00
Ivan Vecera ef3def05c1 net: ethtool: Refactor identical get_ts_info implementations.
JIRA: https://issues.redhat.com/browse/RHEL-36217

commit b8768dc4077712915f045ba1b198f521493c7914
Author: Richard Cochran <richardcochran@gmail.com>
Date:   Tue Nov 14 12:28:31 2023 +0100

    net: ethtool: Refactor identical get_ts_info implementations.

    The vlan, macvlan and the bonding drivers call their "real" device driver
    in order to report the time stamping capabilities.  Provide a core
    ethtool helper function to avoid copy/paste in the stack.

    Signed-off-by: Richard Cochran <richardcochran@gmail.com>
    Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
    Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
    Reviewed-by: Jay Vosburgh <jay.vosburgh@canonical.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-05-16 18:34:22 +02:00
Ivan Vecera 6d5dcfe050 net_tstamp: add SOF_TIMESTAMPING_OPT_ID_TCP
JIRA: https://issues.redhat.com/browse/RHEL-36217

commit b534dc46c8ae0165b1b2509be24dbea4fa9c4011
Author: Willem de Bruijn <willemb@google.com>
Date:   Wed Dec 7 09:37:01 2022 -0500

    net_tstamp: add SOF_TIMESTAMPING_OPT_ID_TCP

    Add an option to initialize SOF_TIMESTAMPING_OPT_ID for TCP from
    write_seq sockets instead of snd_una.

    This should have been the behavior from the start. Because processes
    may now exist that rely on the established behavior, do not change
    behavior of the existing option, but add the right behavior with a new
    flag. It is encouraged to always set SOF_TIMESTAMPING_OPT_ID_TCP on
    stream sockets along with the existing SOF_TIMESTAMPING_OPT_ID.

    Intuitively the contract is that the counter is zero after the
    setsockopt, so that the next write N results in a notification for
    the last byte N - 1.

    On idle sockets snd_una == write_seq and this holds for both. But on
    sockets with data in transmission, snd_una records the unacked offset
    in the stream. This depends on the ACK response from the peer. A
    process cannot learn this in a race free manner (ioctl SIOCOUTQ is one
    racy approach).

    write_seq records the offset at the last byte written by the process.
    This is a better starting point. It matches the intuitive contract in
    all circumstances, unaffected by external behavior.

    The new timestamp flag necessitates increasing sk_tsflags to 32 bits.
    Move the field in struct sock to avoid growing the socket (for some
    common CONFIG variants). The UAPI interface so_timestamping.flags is
    already int, so 32 bits wide.

    Reported-by: Sotirios Delimanolis <sotodel@meta.com>
    Signed-off-by: Willem de Bruijn <willemb@google.com>
    Link: https://lore.kernel.org/r/20221207143701.29861-1-willemdebruijn.kernel@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-05-16 18:34:21 +02:00
Ivan Vecera 3ed53337dc ethtool: add linkmode bitmap support to struct ethtool_keee
JIRA: https://issues.redhat.com/browse/RHEL-32101

commit 1f069de63602e8d39d7d9fd6195f65235316f79a
Author: Heiner Kallweit <hkallweit1@gmail.com>
Date:   Sat Jan 27 14:29:33 2024 +0100

    ethtool: add linkmode bitmap support to struct ethtool_keee

    Add linkmode bitmap members to struct ethtool_keee, but keep the legacy
    u32 bitmaps for compatibility with existing drivers.
    Use linkmode "supported" not being empty as indicator that a user wants
    to use the linkmode bitmap members instead of the legacy bitmaps.

    Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-29 12:11:45 +02:00
Ivan Vecera 6555e8128e net: ethtool: pass a pointer to parameters to get/set_rxfh ethtool ops
JIRA: https://issues.redhat.com/browse/RHEL-31889

Conflicts:
- drivers/net/ethernet/fungible/funeth/funeth_ethtool.c
  hunk removed as the file does not exist in RHEL

commit fb6e30a72539ce28c1323aef4190d35aac106f6f
Author: Ahmed Zaki <ahmed.zaki@intel.com>
Date:   Tue Dec 12 17:33:14 2023 -0700

    net: ethtool: pass a pointer to parameters to get/set_rxfh ethtool ops

    The get/set_rxfh ethtool ops currently takes the rxfh (RSS) parameters
    as direct function arguments. This will force us to change the API (and
    all drivers' functions) every time some new parameters are added.

    This is part 1/2 of the fix, as suggested in [1]:

    - First simplify the code by always providing a pointer to all params
       (indir, key and func); the fact that some of them may be NULL seems
       like a weird historic thing or a premature optimization.
       It will simplify the drivers if all pointers are always present.

     - Then make the functions take a dev pointer, and a pointer to a
       single struct wrapping all arguments. The set_* should also take
       an extack.

    Link: https://lore.kernel.org/netdev/20231121152906.2dd5f487@kernel.org/ [1]
    Suggested-by: Jakub Kicinski <kuba@kernel.org>
    Suggested-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
    Link: https://lore.kernel.org/r/20231213003321.605376-2-ahmed.zaki@intel.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:30:33 +02:00
Scott Weaver 056c8bbdac Merge: CNB94: phy: update to v6.6
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3336

JIRA: https://issues.redhat.com/browse/RHEL-946

Signed-off-by: Izabela Bakollari <ibakolla@redhat.com>

Approved-by: Ivan Vecera <ivecera@redhat.com>
Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com>
Approved-by: Petr Oros <poros@redhat.com>

Signed-off-by: Scott Weaver <scweaver@redhat.com>
2024-01-24 12:32:26 -05:00
Izabela Bakollari edb726666b net: transfer rtnl_lock() requirement from ethtool_set_ethtool_phy_ops() to caller
JIRA: https://issues.redhat.com/browse/RHEL-946

commit 70ef7d87f62a86674c21a99341dabc175c19681a
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Aug 1 17:28:22 2023 +0300

    net: transfer rtnl_lock() requirement from ethtool_set_ethtool_phy_ops() to caller

    phy_init() and phy_exit() will have to do more stuff under rtnl_lock()
    in a future change. Since rtnl_unlock() -> netdev_run_todo() does a lot
    of stuff under the hood, it's a pity to lock and unlock the rtnetlink
    mutex twice in a row.

    Change the calling convention such that the only caller of
    ethtool_set_ethtool_phy_ops(), phy_device.c, provides a context where
    the rtnl_mutex is already acquired.

    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Link: https://lore.kernel.org/r/20230801142824.1772134-11-vladimir.oltean@nxp.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Izabela Bakollari <ibakolla@redhat.com>
2024-01-09 11:58:39 +01:00
Petr Oros c8426fafd4 ethtool: untangle the linkmode and ethtool headers
JIRA: https://issues.redhat.com/browse/RHEL-20012

Upstream commit(s):
commit 20c6e05bd33deaa6fa890252d7ffc5ad54a0942c
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Thu Oct 19 08:28:15 2023 -0700

    ethtool: untangle the linkmode and ethtool headers

    Commit 26c5334d344d ("ethtool: Add forced speed to supported link
    modes maps") added a dependency between ethtool.h and linkmode.h.
    The dependency in the opposite direction already exists so the
    new code was inserted in an awkward place.

    The reason for ethtool.h to include linkmode.h, is that
    ethtool_forced_speed_maps_init() is a static inline helper.
    That's not really necessary.

    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Reviewed-by: Paul Greenwalt <paul.greenwalt@intel.com>
    Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-01-08 10:24:36 +01:00
Adrien Thierry fff4f1a70c drivers/net/phy: add the link modes for the 10BASE-T1S Ethernet PHY
JIRA: https://issues.redhat.com/browse/RHEL-2799

commit 16178c8ef53dc9734302c4c07633696454579ee3
Author: Piergiorgio Beruto <piergiorgio.beruto@gmail.com>
Date:   Mon Jan 9 17:59:58 2023 +0100

    drivers/net/phy: add the link modes for the 10BASE-T1S Ethernet PHY

    This patch adds the link modes for the IEEE 802.3cg Clause 147 10BASE-T1S
    Ethernet PHY. According to the specifications, the 10BASE-T1S supports
    Point-To-Point Full-Duplex, Point-To-Point Half-Duplex and/or
    Point-To-Multipoint (AKA Multi-Drop) Half-Duplex operations.

    Signed-off-by: Piergiorgio Beruto <piergiorgio.beruto@gmail.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Adrien Thierry <athierry@redhat.com>
2023-09-19 14:18:05 -04:00
Ivan Vecera 9ba778caec ethtool: Fail number of channels change when it conflicts with rxnfc
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2175237

commit 47f3ecf4763d3fea37d3453c9ee1f9f2169d71b3
Author: Gal Pressman <gal@nvidia.com>
Date:   Sun Nov 6 14:31:27 2022 +0200

    ethtool: Fail number of channels change when it conflicts with rxnfc

    Similar to what we do with the hash indirection table [1], when network
    flow classification rules are forwarding traffic to channels greater
    than the requested number of channels, fail the operation.
    Without this, traffic could be directed to channels which no longer
    exist (dropped) after changing number of channels.

    [1] commit d4ab428627 ("ethtool: correctly ensure {GS}CHANNELS doesn't conflict with GS{RXFH}")

    Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
    Signed-off-by: Gal Pressman <gal@nvidia.com>
    Link: https://lore.kernel.org/r/20221106123127.522985-1-gal@nvidia.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2023-03-31 18:02:50 +02:00
Ivan Vecera c22713fffc ethtool: Add support for 800Gbps link modes
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2175237

commit 404c76783f322120266a4ef659abe418dc74f5c6
Author: Amit Cohen <amcohen@nvidia.com>
Date:   Thu Oct 20 17:20:03 2022 +0200

    ethtool: Add support for 800Gbps link modes

    Add support for 800Gbps speed, link modes of 100Gbps per lane.
    As mentioned in slide 21 in IEEE documentation [1], all adopted 802.3df
    copper and optical PMDs baselines using 100G/lane will be supported.

    Add the relevant PMDs which are mentioned in slide 5 in IEEE
    documentation [1] and were approved on 10-2022 [2]:
    BP - KR8
    Cu Cable - CR8
    MMF 50m - VR8
    MMF 100m - SR8
    SMF 500m - DR8
    SMF 2km - DR8-2

    [1]: https://www.ieee802.org/3/df/public/22_10/22_1004/shrikhande_3df_01a_221004.pdf
    [2]: https://ieee802.org/3/df/KeyMotions_3df_221005.pdf

    Signed-off-by: Amit Cohen <amcohen@nvidia.com>
    Reviewed-by: Ido Schimmel <idosch@nvidia.com>
    Signed-off-by: Petr Machata <petrm@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2023-03-31 18:02:50 +02:00
Al Stone 46db946bd8 ethtool: Add 10base-T1L link mode entry
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071844
Depends: https://bugzilla.redhat.com/show_bug.cgi?id=2121508
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
 support in the kernel for NXP i.MX8 platforms.  This set cleans up
 PHY handling for imx8m (and Tegra) in drivers/phy.  This set has been
 tested via simple boot tests, and of course the CI loop.  If the PHYs
 are not working, their devices aren't; everything appears to be
 working just fine.

commit 3254e0b9eb5649ffaa48717ebc9c593adc4ee6a9
Author: Alexandru Tachici <alexandru.tachici@analog.com>
Date:   Fri Apr 29 18:34:31 2022 +0300

    ethtool: Add 10base-T1L link mode entry

    Add entry for the 10base-T1L full duplex mode.

    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
    Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    (cherry picked from commit 3254e0b9eb5649ffaa48717ebc9c593adc4ee6a9)

Signed-off-by: Al Stone <ahs3@redhat.com>
2022-10-13 10:24:04 -06:00
Ivan Vecera a655b9272b ethtool: add support to set/get tx copybreak buf size via ethtool
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2047636

commit 448f413a8bdc727d25d9a786ccbdb974fb85d973
Author: Hao Chen <chenhao288@hisilicon.com>
Date:   Thu Nov 18 20:12:40 2021 +0800

    ethtool: add support to set/get tx copybreak buf size via ethtool

    Add support for ethtool to set/get tx copybreak buf size.

    Signed-off-by: Hao Chen <chenhao288@hisilicon.com>
    Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2022-01-28 15:55:56 +01:00
Yangbo Lu d463126e23 net: sock: extend SO_TIMESTAMPING for PHC binding
Since PTP virtual clock support is added, there can be
several PTP virtual clocks based on one PTP physical
clock for timestamping.

This patch is to extend SO_TIMESTAMPING API to support
PHC (PTP Hardware Clock) binding by adding a new flag
SOF_TIMESTAMPING_BIND_PHC. When PTP virtual clocks are
in use, user space can configure to bind one for
timestamping, but PTP physical clock is not supported
and not needed to bind.

This patch is preparation for timestamp conversion from
raw timestamp to a specific PTP virtual clock time in
core net.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-07-01 13:08:18 -07:00
Yangbo Lu c156174a67 ethtool: add a new command for getting PHC virtual clocks
Add an interface for getting PHC (PTP Hardware Clock)
virtual clocks, which are based on PHC physical clock
providing hardware timestamp to network packets.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-07-01 13:08:18 -07:00
Danielle Ratson fde32dbe71 ethtool: Add lanes parameter for ETHTOOL_LINK_MODE_10000baseR_FEC_BIT
Lanes field is missing for ETHTOOL_LINK_MODE_10000baseR_FEC_BIT
link mode and it causes a failure when trying to set
'speed 10000 lanes 1' on Spectrum-2 machines when autoneg is set to on.

Add the lanes parameter for ETHTOOL_LINK_MODE_10000baseR_FEC_BIT
link mode.

Fixes: c8907043c6 ("ethtool: Get link mode in use instead of speed and duplex parameters")
Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-04-07 14:53:04 -07:00
Danielle Ratson a975d7d8a3 ethtool: Remove link_mode param and derive link params from driver
Some drivers clear the 'ethtool_link_ksettings' struct in their
get_link_ksettings() callback, before populating it with actual values.
Such drivers will set the new 'link_mode' field to zero, resulting in
user space receiving wrong link mode information given that zero is a
valid value for the field.

Another problem is that some drivers (notably tun) can report random
values in the 'link_mode' field. This can result in a general protection
fault when the field is used as an index to the 'link_mode_params' array
[1].

This happens because such drivers implement their set_link_ksettings()
callback by simply overwriting their private copy of
'ethtool_link_ksettings' struct with the one they get from the stack,
which is not always properly initialized.

Fix these problems by removing 'link_mode' from 'ethtool_link_ksettings'
and instead have drivers call ethtool_params_from_link_mode() with the
current link mode. The function will derive the link parameters (e.g.,
speed) from the link mode and fill them in the 'ethtool_link_ksettings'
struct.

v3:
	* Remove link_mode parameter and derive the link parameters in
	  the driver instead of passing link_mode parameter to ethtool
	  and derive it there.

v2:
	* Introduce 'cap_link_mode_supported' instead of adding a
	  validity field to 'ethtool_link_ksettings' struct.

[1]
general protection fault, probably for non-canonical address 0xdffffc00f14cc32c: 0000 [#1] PREEMPT SMP KASAN
KASAN: probably user-memory-access in range [0x000000078a661960-0x000000078a661967]
CPU: 0 PID: 8452 Comm: syz-executor360 Not tainted 5.11.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__ethtool_get_link_ksettings+0x1a3/0x3a0 net/ethtool/ioctl.c:446
Code: b7 3e fa 83 fd ff 0f 84 30 01 00 00 e8 16 b0 3e fa 48 8d 3c ed 60 d5 69 8a 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48 89 f8 83 e0 07 83 c0 03
+38 d0 7c 08 84 d2 0f 85 b9
RSP: 0018:ffffc900019df7a0 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: ffff888026136008 RCX: 0000000000000000
RDX: 00000000f14cc32c RSI: ffffffff873439ca RDI: 000000078a661960
RBP: 00000000ffff8880 R08: 00000000ffffffff R09: ffff88802613606f
R10: ffffffff873439bc R11: 0000000000000000 R12: 0000000000000000
R13: ffff88802613606c R14: ffff888011d0c210 R15: ffff888011d0c210
FS:  0000000000749300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000004b60f0 CR3: 00000000185c2000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 linkinfo_prepare_data+0xfd/0x280 net/ethtool/linkinfo.c:37
 ethnl_default_notify+0x1dc/0x630 net/ethtool/netlink.c:586
 ethtool_notify+0xbd/0x1f0 net/ethtool/netlink.c:656
 ethtool_set_link_ksettings+0x277/0x330 net/ethtool/ioctl.c:620
 dev_ethtool+0x2b35/0x45d0 net/ethtool/ioctl.c:2842
 dev_ioctl+0x463/0xb70 net/core/dev_ioctl.c:440
 sock_do_ioctl+0x148/0x2d0 net/socket.c:1060
 sock_ioctl+0x477/0x6a0 net/socket.c:1177
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl fs/ioctl.c:739 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:739
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fixes: c8907043c6 ("ethtool: Get link mode in use instead of speed and duplex parameters")
Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-04-07 14:53:04 -07:00
George McCollister dcf0cd1cc5 net: hsr: add offloading support
Add support for offloading of HSR/PRP (IEC 62439-3) tag insertion
tag removal, duplicate generation and forwarding.

For HSR, insertion involves the switch adding a 6 byte HSR header after
the 14 byte Ethernet header. For PRP it adds a 6 byte trailer.

Tag removal involves automatically stripping the HSR/PRP header/trailer
in the switch. This is possible when the switch also performs auto
deduplication using the HSR/PRP header/trailer (making it no longer
required).

Forwarding involves automatically forwarding between redundant ports in
an HSR. This is crucial because delay is accumulated as a frame passes
through each node in the ring.

Duplication involves the switch automatically sending a single frame
from the CPU port to both redundant ports. This is required because the
inserted HSR/PRP header/trailer must contain the same sequence number
on the frames sent out both redundant ports.

Export is_hsr_master so DSA can tell them apart from other devices in
dsa_slave_changeupper.

Signed-off-by: George McCollister <george.mccollister@gmail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-02-11 13:24:44 -08:00
Danielle Ratson c8907043c6 ethtool: Get link mode in use instead of speed and duplex parameters
Currently, when user space queries the link's parameters, as speed and
duplex, each parameter is passed from the driver to ethtool.

Instead, get the link mode bit in use, and derive each of the parameters
from it in ethtool.

Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-02-03 18:37:29 -08:00
Alexander Lobakin 6f1c0ea133 net: introduce a netdev feature for UDP GRO forwarding
Introduce a new netdev feature, NETIF_F_GRO_UDP_FWD, to allow user
to turn UDP GRO on and off for forwarding.
Defaults to off to not change current datapath.

Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-01-23 20:16:24 -08:00
Dan Murphy 55f1331178 ethtool: Add 100base-FX link mode entries
Add entries for the 100base-FX full and half duplex supported modes.

$ ethtool eth0
        Supported ports: [ FIBRE ]
        Supported link modes:  100baseFX/Half 100baseFX/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: No
        Supported FEC modes: Not reported
        Advertised link modes: 100baseFX/Half 100baseFX/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Advertised FEC modes: Not reported
        Speed: 100Mb/s
        Duplex: Full
        Auto-negotiation: off
        Port: MII
        PHYAD: 1
        Transceiver: external
        Supports Wake-on: gs
        Wake-on: d
        SecureOn password: 00:00:00:00:00:00
        Current message level: 0x00000000 (0)

        Link detected: yes

Signed-off-by: Dan Murphy <dmurphy@ti.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-09-19 16:54:35 -07:00
Jakub Kicinski c7d759eb7b ethtool: add tunnel info interface
Add an interface to report offloaded UDP ports via ethtool netlink.

Now that core takes care of tracking which UDP tunnel ports the NICs
are aware of we can quite easily export this information out to
user space.

The responsibility of writing the netlink dumps is split between
ethtool code and udp_tunnel_nic.c - since udp_tunnel module may
not always be loaded, yet we should always report the capabilities
of the NIC.

$ ethtool --show-tunnels eth0
Tunnel information for eth0:
  UDP port table 0:
    Size: 4
    Types: vxlan
    No entries
  UDP port table 1:
    Size: 4
    Types: geneve, vxlan-gpe
    Entries (1):
        port 1230, vxlan-gpe

v4:
 - back to v2, build fix is now directly in udp_tunnel.h
v3:
 - don't compile ETHTOOL_MSG_TUNNEL_INFO_GET in if CONFIG_INET
   not set.
v2:
 - fix string set count,
 - reorder enums in the uAPI,
 - fix type of ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES to bitset
   in docs and comments.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-10 13:54:00 -07:00
Meir Lichtinger 065e0d42a0 ethtool: Add support for 100Gbps per lane link modes
Define 100G, 200G and 400G link modes using 100Gbps per lane

LR, ER and FR are defined as a single link mode because they are
using same technology and by design are fully interoperable.
EEPROM content indicates if the module is LR, ER, or FR, and the
user space ethtool decoder is planned to support decoding these
modes in the EEPROM.

Signed-off-by: Meir Lichtinger <meirl@mellanox.com>
CC: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-08 15:30:42 -07:00
Florian Fainelli 4895d7808e net: ethtool: Introduce ethtool_phy_ops
In order to decouple ethtool from its PHY library dependency, define an
ethtool_phy_ops singleton which can be overriden by the PHY library when
it loads with an appropriate set of function pointers.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-07 15:41:04 -07:00
Alexander Lobakin b4730ae6a4 net: ethtool: add missing string for NETIF_F_GSO_TUNNEL_REMCSUM
Commit e585f23636 ("udp: Changes to udp_offload to support remote
checksum offload") added new GSO type and a corresponding netdev
feature, but missed Ethtool's 'netdev_features_strings' table.
Give it a name so it will be exposed to userspace and become available
for manual configuration.

v3:
 - decouple from "netdev_features_strings[] cleanup" series;
 - no functional changes.

v2:
 - don't split the "Fixes:" tag across lines;
 - no functional changes.

Fixes: e585f23636 ("udp: Changes to udp_offload to support remote checksum offload")
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-06-23 14:52:27 -07:00
Alexander Lobakin eddbf5d020 net: ethtool: add missing NETIF_F_GSO_FRAGLIST feature string
Commit 3b33583265 ("net: Add fraglist GRO/GSO feature flags") missed
an entry for NETIF_F_GSO_FRAGLIST in netdev_features_strings array. As
a result, fraglist GSO feature is not shown in 'ethtool -k' output and
can't be toggled on/off.
The fix is trivial.

Fixes: 3b33583265 ("net: Add fraglist GRO/GSO feature flags")
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-06-18 20:37:11 -07:00
Michal Kubecek 5b071c59ed ethtool: provide timestamping information with TSINFO_GET request
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 <mkubecek@suse.cz>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-29 22:32:37 -07:00
Michal Kubecek f76510b458 ethtool: add timestamping related string sets
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 <mkubecek@suse.cz>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-29 22:32:36 -07:00
Antoine Tenart 5908220b2b net: introduce the MACSEC netdev feature
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 <antoine.tenart@bootlin.com>
Signed-off-by: Mark Starovoytov <mstarovoitov@marvell.com>
Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-26 20:17:36 -07:00
Jakub Kicinski 9000edb71a net: ethtool: require drivers to set supported_coalesce_params
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 <kuba@kernel.org>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-17 20:56:58 -07:00
Michal Kubecek e19c591eaf ethtool: set device channel counts with CHANNELS_SET request
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 <mkubecek@suse.cz>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-12 15:32:33 -07:00
Aya Levin f623e59705 ethtool: Add support for low latency RS FEC
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 <ayal@mellanox.com>
Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
CC: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
2020-02-18 19:17:31 -08:00
Michal Kubecek 51ea22b04e ethtool: provide WoL settings with WOL_GET request
Implement WOL_GET request to get wake-on-lan settings for a device,
traditionally available via ETHTOOL_GWOL ioctl request.

As part of the implementation, provide symbolic names for wake-on-line
modes as ETH_SS_WOL_MODES string set.

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-01-27 11:31:36 +01:00