net: Use conftest

Instead of relying on kernel version to determine if functions or
specific versions of functions are present in the kernel, add compile
time tests to the conftest.sh script to determine this at compile time
for the kernel being used. This is beneficial for working with 3rd party
Linux kernels that may have back-ported upstream changes into their
kernel and so the kernel version checks do not work.

Bug 4119327

Change-Id: I79e701940ca70ca4d66500c75b5992f9d92b54b0
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2985744
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2023-09-26 11:26:03 +01:00
committed by mobile promotions
parent 3dbf9a344e
commit ece68dd0d1
9 changed files with 125 additions and 23 deletions

View File

@@ -98,8 +98,13 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_prepare_has_preferred_bpp_ar
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 += 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 += iio_dev_opaque_has_mlock
NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_set_tso_max_size
NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_napi_add_weight
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data
NV_CONFTEST_FUNCTION_COMPILE_TESTS += register_shrinker_has_fmt_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_ivc_struct_has_iosys_map
NV_CONFTEST_GENERIC_COMPILE_TESTS ?=

View File

@@ -6483,6 +6483,89 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DRM_MODE_CONFIG_STRUCT_HAS_FB_BASE_ARG" "" "types"
;;
ethtool_ops_get_set_coalesce_has_coal_and_extack_args)
#
# Determine if the 'get_coalesce' and 'set_coalesce' ethtool_ops
# callback functions support the 'kernel_ethtool_coalesce' and
# 'netlink_ext_ack' arguments.
#
# Added by commit f3ccfda19319 ("ethtool: extend coalesce setting
# uAPI with CQE mode") in Linux v5.15.
#
CODE="
#include <linux/ethtool.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <uapi/linux/ethtool.h>
void conftest_ethtool_ops_get_set_coalesce_has_coal_and_extack_args(struct ethtool_ops *ops) {
int (*fn)(struct net_device *,
struct ethtool_coalesce *,
struct kernel_ethtool_coalesce *,
struct netlink_ext_ack *) = ops->get_coalesce;
}"
compile_check_conftest "$CODE" "NV_ETHTOOL_OPS_GET_SET_COALESCE_HAS_COAL_AND_EXTACT_ARGS" "" "types"
;;
ethtool_ops_get_set_ringparam_has_ringparam_and_extack_args)
#
# Determine if the 'get_ringparam' and 'set_ringparam' ethtool_ops
# callback functions support the 'kernel_ethtool_ringparam' and
# 'netlink_ext_ack' arguments.
#
# Added by commit 7462494408cd ("ethtool: extend ringparam
# setting/getting API with rx_buf_len") in Linux v5.17.
#
CODE="
#include <linux/ethtool.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <uapi/linux/ethtool.h>
void conftest_ethtool_ops_get_set_ringparam_has_ringparam_and_extack_args(struct ethtool_ops *ops) {
void (*fn)(struct net_device *,
struct ethtool_ringparam *,
struct kernel_ethtool_ringparam *,
struct netlink_ext_ack *) = ops->get_ringparam;
}"
compile_check_conftest "$CODE" "NV_ETHTOOL_OPS_GET_SET_RINGPARAM_HAS_RINGPARAM_AND_EXTACT_ARGS" "" "types"
;;
netif_set_tso_max_size)
#
# Determine if netif_set_tso_max_size() function is present
#
# Added by commit 14d7b8122fd5 ("net: don't allow user space
# to lift the device limits") in Linux v5.19.
#
CODE="
#include <linux/netdevice.h>
void conftest_netif_set_tso_max_size(void)
{
netif_set_tso_max_size();
}
"
compile_check_conftest "$CODE" "NV_NETIF_SET_TSO_MAX_SIZE_PRESENT" "" "functions"
;;
netif_napi_add_weight)
#
# Determine if netif_napi_add_weight() function is present
#
# Added by commit 58caed3dacb4 ("netdev: reshuffle netif_napi_add()
# APIs to allow dropping weight") in Linux v6.1.
#
CODE="
#include <linux/netdevice.h>
void conftest_netif_napi_add_weight(void)
{
netif_napi_add_weight();
}
"
compile_check_conftest "$CODE" "NV_NETIF_NAPI_ADD_WEIGHT_PRESENT" "" "functions"
;;
iommu_map_has_gfp_arg)
#
# Determine if iommu_map() has 'gfp' argument.