diff --git a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c index dd082670..261f4ddf 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -// Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. #include @@ -1095,7 +1095,11 @@ static int ether_get_coalesce(struct net_device *dev, * @retval -ve on Failure */ static int ether_get_eee(struct net_device *ndev, +#if defined(NV_ETHTOOL_KEEE_STRUCT_PRESENT) /* Linux v6.9 */ + struct ethtool_keee *cur_eee) +#else struct ethtool_eee *cur_eee) +#endif { int ret; struct ether_priv_data *pdata = netdev_priv(ndev); @@ -1136,8 +1140,13 @@ static int ether_get_eee(struct net_device *ndev, * @retval none */ static inline void validate_eee_conf(struct net_device *ndev, +#if defined(NV_ETHTOOL_KEEE_STRUCT_PRESENT) /* Linux v6.9 */ + struct ethtool_keee *eee_req, + struct ethtool_keee cur_eee) +#else struct ethtool_eee *eee_req, struct ethtool_eee cur_eee) +#endif { /* These are the invalid combinations that can be requested. * EEE | Tx LPI | Rx LPI @@ -1155,7 +1164,11 @@ static inline void validate_eee_conf(struct net_device *ndev, eee_req->advertised) { if (eee_req->eee_enabled != cur_eee.eee_enabled) { netdev_warn(ndev, "EEE off. Set Rx LPI off\n"); +#if defined(NV_ETHTOOL_KEEE_STRUCT_PRESENT) /* Linux v6.9 */ + linkmode_zero(eee_req->advertised); +#else eee_req->advertised = OSI_DISABLE; +#endif } else { netdev_warn(ndev, "Rx LPI on. Set EEE on\n"); eee_req->eee_enabled = OSI_ENABLE; @@ -1174,7 +1187,11 @@ static inline void validate_eee_conf(struct net_device *ndev, */ netdev_warn(ndev, "Tx LPI on. Set EEE & Rx LPI on\n"); eee_req->eee_enabled = OSI_ENABLE; +#if defined(NV_ETHTOOL_KEEE_STRUCT_PRESENT) /* Linux v6.9 */ + linkmode_copy(eee_req->advertised, eee_req->supported); +#else eee_req->advertised = eee_req->supported; +#endif } } @@ -1183,7 +1200,11 @@ static inline void validate_eee_conf(struct net_device *ndev, if (eee_req->eee_enabled != cur_eee.eee_enabled) { netdev_warn(ndev, "EEE off. Set Tx & Rx LPI off\n"); eee_req->tx_lpi_enabled = OSI_DISABLE; +#if defined(NV_ETHTOOL_KEEE_STRUCT_PRESENT) /* Linux v6.9 */ + linkmode_zero(eee_req->advertised); +#else eee_req->advertised = OSI_DISABLE; +#endif } else { netdev_warn(ndev, "Tx & Rx LPI on. Set EEE on\n"); eee_req->eee_enabled = OSI_ENABLE; @@ -1195,7 +1216,11 @@ static inline void validate_eee_conf(struct net_device *ndev, if (eee_req->eee_enabled != cur_eee.eee_enabled) { netdev_warn(ndev, "EEE on. Set Tx & Rx LPI on\n"); eee_req->tx_lpi_enabled = OSI_ENABLE; +#if defined(NV_ETHTOOL_KEEE_STRUCT_PRESENT) /* Linux v6.9 */ + linkmode_copy(eee_req->advertised, eee_req->supported); +#else eee_req->advertised = eee_req->supported; +#endif } else { netdev_warn(ndev, "Tx,Rx LPI off. Set EEE off\n"); eee_req->eee_enabled = OSI_DISABLE; @@ -1218,11 +1243,19 @@ static inline void validate_eee_conf(struct net_device *ndev, * @retval -ve on Failure */ static int ether_set_eee(struct net_device *ndev, +#if defined(NV_ETHTOOL_KEEE_STRUCT_PRESENT) /* Linux v6.9 */ + struct ethtool_keee *eee_req) +#else struct ethtool_eee *eee_req) +#endif { struct ether_priv_data *pdata = netdev_priv(ndev); struct phy_device *phydev = pdata->phydev; +#if defined(NV_ETHTOOL_KEEE_STRUCT_PRESENT) /* Linux v6.9 */ + struct ethtool_keee cur_eee; +#else struct ethtool_eee cur_eee; +#endif if (!pdata->hw_feat.eee_sel) { return -EOPNOTSUPP; diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 2ae1a0a4..771072f7 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -115,6 +115,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_unregister_info NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_struct_has_info_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_mode_config_struct_has_fb_base_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_scdc_get_set_has_struct_drm_connector_arg +NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_keee_struct_present NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_coalesce_has_coal_and_extack_args NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_ringparam_has_ringparam_and_extack_args NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_rxfh_has_rxfh_param_args diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 11d376f9..50a8ca47 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -6954,6 +6954,23 @@ compile_test() { "NV_DRM_SCDC_GET_SET_HAS_STRUCT_DRM_CONNECTOR_ARG" "" "types" ;; + ethtool_keee_struct_present) + # + # Determine if the 'struct ethtool_keee' is present. + # + # Commit d80a52335374 ("ethtool: replace struct ethtool_eee with a + # new struct ethtool_keee on kernel side") replaced struct + # ethtool_eee with ethtool_keee in Linux v6.9. + # + CODE=" + #include + int conftest_ethtool_keee_struct_present(struct ethtool_keee *keee) { + return 0; + }" + + compile_check_conftest "$CODE" "NV_ETHTOOL_KEEE_STRUCT_PRESENT" "" "types" + ;; + ethtool_ops_get_set_coalesce_has_coal_and_extack_args) # # Determine if the 'get_coalesce' and 'set_coalesce' ethtool_ops