From 0356a563b32710fcfa8d476deaca6e3ea930f589 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Tue, 19 Dec 2023 12:27:25 +0000 Subject: [PATCH] net: nvethernet: Fix build for Linux v6.8 The ethtool_ops function pointers get_rxfh and set_rxfh were updated for Linux v6.8 to pass arguments via a new 'ethtool_rxfh_param' structure. Add a new test for conftest to detect if the get_rxfh and set_rxfh functions support the 'ethtool_rxfh_param' structure and update the nvethernet driver accordingly for Linux v6.8. Bug 4448428 Change-Id: Ia1c49d88c4ac73539454b010af92c261e14be4bf Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3037949 Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- .../net/ethernet/nvidia/nvethernet/ethtool.c | 23 ++++++++++++++++++- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 22 ++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ethtool.c b/drivers/net/ethernet/nvidia/nvethernet/ethtool.c index 28495c40..dd082670 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-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. #include @@ -1455,11 +1455,21 @@ static u32 ether_get_rxfh_indir_size(struct net_device *ndev) * * @retval 0 on success */ +#if defined(NV_ETHTOOL_OPS_GET_SET_RXFH_HAS_RXFH_PARAM_ARGS) +static int ether_get_rxfh(struct net_device *ndev, + struct ethtool_rxfh_param *rxfh) +#else static int ether_get_rxfh(struct net_device *ndev, u32 *indir, u8 *key, u8 *hfunc) +#endif { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_core_priv_data *osi_core = pdata->osi_core; +#if defined(NV_ETHTOOL_OPS_GET_SET_RXFH_HAS_RXFH_PARAM_ARGS) + u32 *indir = rxfh->indir; + u8 *hfunc = &rxfh->hfunc; + u8 *key = rxfh->key; +#endif int i; if (indir) { @@ -1487,12 +1497,23 @@ static int ether_get_rxfh(struct net_device *ndev, u32 *indir, u8 *key, * @retval 0 on success * @retval -1 on failure. */ +#if defined(NV_ETHTOOL_OPS_GET_SET_RXFH_HAS_RXFH_PARAM_ARGS) +static int ether_set_rxfh(struct net_device *ndev, + struct ethtool_rxfh_param *rxfh, + struct netlink_ext_ack *extack) +#else static int ether_set_rxfh(struct net_device *ndev, const u32 *indir, const u8 *key, const u8 hfunc) +#endif { struct ether_priv_data *pdata = netdev_priv(ndev); struct osi_core_priv_data *osi_core = pdata->osi_core; struct osi_ioctl ioctl_data = {}; +#if defined(NV_ETHTOOL_OPS_GET_SET_RXFH_HAS_RXFH_PARAM_ARGS) + u32 *indir = rxfh->indir; + u8 hfunc = rxfh->hfunc; + u8 *key = rxfh->key; +#endif int i; if (!netif_running(ndev)) { diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 0c3e50a3..975891c5 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -117,6 +117,7 @@ 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_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 NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_file_rcu_has_double_ptr_file_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_new_client_device diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 86298c1e..29e6ac8d 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7035,6 +7035,28 @@ compile_test() { compile_check_conftest "$CODE" "NV_ETHTOOL_OPS_GET_SET_RINGPARAM_HAS_RINGPARAM_AND_EXTACT_ARGS" "" "types" ;; + ethtool_ops_get_set_rxfh_has_rxfh_param_args) + # + # Determine if the 'get_rxfh' and 'set_rxfh' ethtool_ops functions + # support the 'ethtool_rxfh_param' argument. + # + # Added by commit fb6e30a72539 ("net: ethtool: pass a pointer to + # parameters to get/set_rxfh ethtool ops") in Linux v6.8. + # + CODE=" + #include + #include + #include + #include + void conftest_ethtool_ops_get_set_rxfh_has_rxfh_param_args(struct ethtool_ops *ops) { + int (*fn)(struct net_device *, + struct ethtool_rxfh_param *rxfh) = ops->get_rxfh; + }" + + compile_check_conftest "$CODE" \ + "NV_ETHTOOL_OPS_GET_SET_RXFH_HAS_RXFH_PARAM_ARGS" "" "types" + ;; + netif_set_tso_max_size) # # Determine if netif_set_tso_max_size() function is present