From 72761b82760384567af23a96cdf8c5065bf4d660 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Fri, 5 Apr 2024 19:37:48 +0100 Subject: [PATCH] net: nvethernet: Fix build for Linux v6.9 For Linux v6.9, the structure 'ethtool_eee' was replaced by 'ethtool_keee' and this new structure uses bitmaps for the structure fields 'supported', 'advertised' and 'lp_advertised' as opposed to 'u32' types. Add a test to conftest to detect the presence of the new 'ethtool_keee' structure and update the nvethernet driver to use the various linkmode_xxx helper functions for accessing the bitmap structure fields. Bug 4471899 Change-Id: I275becfa665a36ed90e8bc227eaa4122825faa6a Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3110494 Reviewed-by: Paritosh Dixit Reviewed-by: Brad Griffis --- .../net/ethernet/nvidia/nvethernet/ethtool.c | 35 ++++++++++++++++++- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 17 +++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) 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 b6f3804a..f8371487 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -116,6 +116,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 70e1c2ba..168bf752 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -6987,6 +6987,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