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 <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3110494
Reviewed-by: Paritosh Dixit <paritoshd@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
This commit is contained in:
Jon Hunter
2024-04-05 19:37:48 +01:00
committed by mobile promotions
parent a22321f358
commit 72761b8276
3 changed files with 52 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only // 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 <nvidia/conftest.h> #include <nvidia/conftest.h>
@@ -1095,7 +1095,11 @@ static int ether_get_coalesce(struct net_device *dev,
* @retval -ve on Failure * @retval -ve on Failure
*/ */
static int ether_get_eee(struct net_device *ndev, 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) struct ethtool_eee *cur_eee)
#endif
{ {
int ret; int ret;
struct ether_priv_data *pdata = netdev_priv(ndev); struct ether_priv_data *pdata = netdev_priv(ndev);
@@ -1136,8 +1140,13 @@ static int ether_get_eee(struct net_device *ndev,
* @retval none * @retval none
*/ */
static inline void validate_eee_conf(struct net_device *ndev, 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 *eee_req,
struct ethtool_eee cur_eee) struct ethtool_eee cur_eee)
#endif
{ {
/* These are the invalid combinations that can be requested. /* These are the invalid combinations that can be requested.
* EEE | Tx LPI | Rx LPI * EEE | Tx LPI | Rx LPI
@@ -1155,7 +1164,11 @@ static inline void validate_eee_conf(struct net_device *ndev,
eee_req->advertised) { eee_req->advertised) {
if (eee_req->eee_enabled != cur_eee.eee_enabled) { if (eee_req->eee_enabled != cur_eee.eee_enabled) {
netdev_warn(ndev, "EEE off. Set Rx LPI off\n"); 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; eee_req->advertised = OSI_DISABLE;
#endif
} else { } else {
netdev_warn(ndev, "Rx LPI on. Set EEE on\n"); netdev_warn(ndev, "Rx LPI on. Set EEE on\n");
eee_req->eee_enabled = OSI_ENABLE; 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"); netdev_warn(ndev, "Tx LPI on. Set EEE & Rx LPI on\n");
eee_req->eee_enabled = OSI_ENABLE; 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; 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) { if (eee_req->eee_enabled != cur_eee.eee_enabled) {
netdev_warn(ndev, "EEE off. Set Tx & Rx LPI off\n"); netdev_warn(ndev, "EEE off. Set Tx & Rx LPI off\n");
eee_req->tx_lpi_enabled = OSI_DISABLE; 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; eee_req->advertised = OSI_DISABLE;
#endif
} else { } else {
netdev_warn(ndev, "Tx & Rx LPI on. Set EEE on\n"); netdev_warn(ndev, "Tx & Rx LPI on. Set EEE on\n");
eee_req->eee_enabled = OSI_ENABLE; 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) { if (eee_req->eee_enabled != cur_eee.eee_enabled) {
netdev_warn(ndev, "EEE on. Set Tx & Rx LPI on\n"); netdev_warn(ndev, "EEE on. Set Tx & Rx LPI on\n");
eee_req->tx_lpi_enabled = OSI_ENABLE; 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; eee_req->advertised = eee_req->supported;
#endif
} else { } else {
netdev_warn(ndev, "Tx,Rx LPI off. Set EEE off\n"); netdev_warn(ndev, "Tx,Rx LPI off. Set EEE off\n");
eee_req->eee_enabled = OSI_DISABLE; eee_req->eee_enabled = OSI_DISABLE;
@@ -1218,11 +1243,19 @@ static inline void validate_eee_conf(struct net_device *ndev,
* @retval -ve on Failure * @retval -ve on Failure
*/ */
static int ether_set_eee(struct net_device *ndev, 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) struct ethtool_eee *eee_req)
#endif
{ {
struct ether_priv_data *pdata = netdev_priv(ndev); struct ether_priv_data *pdata = netdev_priv(ndev);
struct phy_device *phydev = pdata->phydev; 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; struct ethtool_eee cur_eee;
#endif
if (!pdata->hw_feat.eee_sel) { if (!pdata->hw_feat.eee_sel) {
return -EOPNOTSUPP; return -EOPNOTSUPP;

View File

@@ -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_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_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 += 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_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_ringparam_has_ringparam_and_extack_args
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_rxfh_has_rxfh_param_args NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_rxfh_has_rxfh_param_args

View File

@@ -6987,6 +6987,23 @@ compile_test() {
"NV_DRM_SCDC_GET_SET_HAS_STRUCT_DRM_CONNECTOR_ARG" "" "types" "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 <linux/ethtool.h>
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) ethtool_ops_get_set_coalesce_has_coal_and_extack_args)
# #
# Determine if the 'get_coalesce' and 'set_coalesce' ethtool_ops # Determine if the 'get_coalesce' and 'set_coalesce' ethtool_ops