mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
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:
committed by
mobile promotions
parent
3dbf9a344e
commit
ece68dd0d1
@@ -3,6 +3,8 @@
|
||||
* Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include "../include/m_ttcan.h"
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/nvpps.h>
|
||||
@@ -1189,7 +1191,7 @@ static struct net_device *alloc_mttcan_dev(void)
|
||||
CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO
|
||||
| CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_ONE_SHOT;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
#if defined(NV_NETIF_NAPI_ADD_WEIGHT_PRESENT) /* Linux v6.1 */
|
||||
netif_napi_add_weight(dev, &priv->napi, mttcan_poll_ir, MTT_CAN_NAPI_WEIGHT);
|
||||
#else
|
||||
netif_napi_add(dev, &priv->napi, mttcan_poll_ir, MTT_CAN_NAPI_WEIGHT);
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
* disclaimer.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#include "oak_net.h"
|
||||
@@ -576,7 +579,7 @@ void oak_net_add_napi(struct net_device *netdev)
|
||||
|
||||
while (num_ldg > 0) {
|
||||
/* Initialize a napi context */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
#if defined(NV_NETIF_NAPI_ADD_WEIGHT_PRESENT) /* Linux v6.1 */
|
||||
netif_napi_add_weight(netdev, &ldg->napi, oak_net_poll, napi_wt);
|
||||
#else
|
||||
netif_napi_add(netdev, &ldg->napi, oak_net_poll, napi_wt);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved */
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/iommu.h>
|
||||
#ifdef HSI_SUPPORT
|
||||
@@ -4409,7 +4411,7 @@ static int ether_alloc_napi(struct ether_priv_data *pdata)
|
||||
|
||||
pdata->tx_napi[chan]->pdata = pdata;
|
||||
pdata->tx_napi[chan]->chan = chan;
|
||||
#if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_NETIF_NAPI_ADD_WEIGHT_PRESENT) /* Linux v6.1 */
|
||||
netif_napi_add_weight(ndev, &pdata->tx_napi[chan]->napi,
|
||||
ether_napi_poll_tx, 64);
|
||||
#else
|
||||
@@ -4427,7 +4429,7 @@ static int ether_alloc_napi(struct ether_priv_data *pdata)
|
||||
|
||||
pdata->rx_napi[chan]->pdata = pdata;
|
||||
pdata->rx_napi[chan]->chan = chan;
|
||||
#if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_NETIF_NAPI_ADD_WEIGHT_PRESENT) /* Linux v6.1 */
|
||||
netif_napi_add_weight(ndev, &pdata->rx_napi[chan]->napi,
|
||||
ether_napi_poll_rx, 64);
|
||||
#else
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/version.h>
|
||||
#include "ether_linux.h"
|
||||
|
||||
@@ -908,7 +910,7 @@ static int ether_get_ts_info(struct net_device *ndev,
|
||||
* @retval 0 on Sucess
|
||||
* @retval "negative value" on failure.
|
||||
*/
|
||||
#if (KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE)
|
||||
#if defined(NV_ETHTOOL_OPS_GET_SET_COALESCE_HAS_COAL_AND_EXTACT_ARGS) /* Linux v5.15 */
|
||||
static int ether_set_coalesce(struct net_device *dev,
|
||||
struct ethtool_coalesce *ec,
|
||||
struct kernel_ethtool_coalesce *kernel_coal,
|
||||
@@ -1049,7 +1051,7 @@ static int ether_set_coalesce(struct net_device *dev,
|
||||
*
|
||||
* @retval 0 on Success.
|
||||
*/
|
||||
#if (KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE)
|
||||
#if defined(NV_ETHTOOL_OPS_GET_SET_COALESCE_HAS_COAL_AND_EXTACT_ARGS) /* Linux v5.15 */
|
||||
static int ether_get_coalesce(struct net_device *dev,
|
||||
struct ethtool_coalesce *ec,
|
||||
struct kernel_ethtool_coalesce *kernel_coal,
|
||||
@@ -1510,7 +1512,7 @@ static int ether_set_rxfh(struct net_device *ndev, const u32 *indir,
|
||||
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(5, 17, 0) <= LINUX_VERSION_CODE)
|
||||
#if defined(NV_ETHTOOL_OPS_GET_SET_RINGPARAM_HAS_RINGPARAM_AND_EXTACT_ARGS) /* Linux v5.17 */
|
||||
static void ether_get_ringparam(struct net_device *ndev,
|
||||
struct ethtool_ringparam *ring,
|
||||
struct kernel_ethtool_ringparam *kernel_ring,
|
||||
@@ -1530,7 +1532,7 @@ static void ether_get_ringparam(struct net_device *ndev,
|
||||
ring->tx_pending = osi_dma->tx_ring_sz;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(5, 17, 0) <= LINUX_VERSION_CODE)
|
||||
#if defined(NV_ETHTOOL_OPS_GET_SET_RINGPARAM_HAS_RINGPARAM_AND_EXTACT_ARGS) /* Linux v5.17 */
|
||||
static int ether_set_ringparam(struct net_device *ndev,
|
||||
struct ethtool_ringparam *ring,
|
||||
struct kernel_ethtool_ringparam *kernel_ring,
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/aer.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/tegra_vnet.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
struct tvnet_priv {
|
||||
struct net_device *ndev;
|
||||
@@ -793,7 +794,7 @@ static int tvnet_host_probe(struct pci_dev *pdev,
|
||||
/* Setup BAR0 meta data */
|
||||
tvnet_host_setup_bar0_md(tvnet);
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
#if defined(NV_NETIF_NAPI_ADD_WEIGHT_PRESENT) /* Linux v6.1 */
|
||||
netif_napi_add_weight(ndev, &tvnet->napi, tvnet_host_poll, TVNET_NAPI_WEIGHT);
|
||||
#else
|
||||
netif_napi_add(ndev, &tvnet->napi, tvnet_host_poll, TVNET_NAPI_WEIGHT);
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
* US6,570,884, US6,115,776, and US6,327,625.
|
||||
***********************************************************************************/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/ethtool.h>
|
||||
#include "r8168_dash.h"
|
||||
#include "r8168_realwow.h"
|
||||
@@ -566,7 +568,7 @@ typedef int *napi_budget;
|
||||
typedef struct napi_struct *napi_ptr;
|
||||
typedef int napi_budget;
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_NETIF_NAPI_ADD_WEIGHT_PRESENT) /* Linux v6.1 */
|
||||
#define RTL_NAPI_CONFIG(ndev, priv, function, weight) \
|
||||
netif_napi_add_weight(ndev, &priv->napi, function, weight)
|
||||
#else
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
* Redefine it to just asm to enable successful compilation.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/pci.h>
|
||||
@@ -1749,11 +1751,11 @@ static void rtl8168_proc_module_init(void)
|
||||
static int rtl8168_proc_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct net_device *dev = proc_get_parent_data(inode);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)
|
||||
#if defined(NV_PDE_DATA_LOWER_CASE_PRESENT) /* Linux v5.17 */
|
||||
int (*show)(struct seq_file *, void *) = pde_data(inode);
|
||||
#else
|
||||
int (*show)(struct seq_file *, void *) = PDE_DATA(inode);
|
||||
#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)
|
||||
#endif //NV_PDE_DATA_LOWER_CASE_PRESENT
|
||||
|
||||
return single_open(file, show, dev);
|
||||
}
|
||||
@@ -5946,7 +5948,7 @@ rtl8168_wait_for_quiescence(struct net_device *dev)
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)
|
||||
#if defined(NV_ETHTOOL_OPS_GET_SET_RINGPARAM_HAS_RINGPARAM_AND_EXTACT_ARGS) /* Linux v5.17 */
|
||||
static void rtl8168_get_ringparam(struct net_device *dev,
|
||||
struct ethtool_ringparam *ring,
|
||||
struct kernel_ethtool_ringparam *kernel_ring,
|
||||
@@ -5954,7 +5956,7 @@ static void rtl8168_get_ringparam(struct net_device *dev,
|
||||
#else
|
||||
static void rtl8168_get_ringparam(struct net_device *dev,
|
||||
struct ethtool_ringparam *ring)
|
||||
#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)
|
||||
#endif //NV_ETHTOOL_OPS_GET_SET_RINGPARAM_HAS_RINGPARAM_AND_EXTACT_ARGS
|
||||
{
|
||||
struct rtl8168_private *tp = netdev_priv(dev);
|
||||
|
||||
@@ -5964,7 +5966,7 @@ static void rtl8168_get_ringparam(struct net_device *dev,
|
||||
ring->tx_pending = tp->num_tx_desc;
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)
|
||||
#if defined(NV_ETHTOOL_OPS_GET_SET_RINGPARAM_HAS_RINGPARAM_AND_EXTACT_ARGS) /* Linux v5.17 */
|
||||
static int rtl8168_set_ringparam(struct net_device *dev,
|
||||
struct ethtool_ringparam *ring,
|
||||
struct kernel_ethtool_ringparam *kernel_ring,
|
||||
@@ -5972,7 +5974,7 @@ static int rtl8168_set_ringparam(struct net_device *dev,
|
||||
#else
|
||||
static int rtl8168_set_ringparam(struct net_device *dev,
|
||||
struct ethtool_ringparam *ring)
|
||||
#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)
|
||||
#endif //NV_ETHTOOL_OPS_GET_SET_RINGPARAM_HAS_RINGPARAM_AND_EXTACT_ARGS
|
||||
{
|
||||
struct rtl8168_private *tp = netdev_priv(dev);
|
||||
u32 new_rx_count, new_tx_count;
|
||||
@@ -27071,10 +27073,10 @@ rtl8168_init_one(struct pci_dev *pdev,
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
|
||||
if ((tp->mcfg == CFG_METHOD_1) || (tp->mcfg == CFG_METHOD_2) || (tp->mcfg == CFG_METHOD_3)) {
|
||||
dev->hw_features &= ~NETIF_F_IPV6_CSUM;
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)
|
||||
#if defined(NV_NETIF_SET_TSO_MAX_SIZE_PRESENT) /* Linux v5.19 */
|
||||
netif_set_tso_max_size(dev, LSO_64K);
|
||||
netif_set_tso_max_segs(dev, NIC_MAX_PHYS_BUF_COUNT_LSO2);
|
||||
#else //LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)
|
||||
#else //NV_NETIF_SET_TSO_MAX_SIZE_PRESENT
|
||||
netif_set_gso_max_size(dev, LSO_32K);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
|
||||
dev->gso_max_segs = NIC_MAX_PHYS_BUF_COUNT_LSO_64K;
|
||||
@@ -27082,7 +27084,7 @@ rtl8168_init_one(struct pci_dev *pdev,
|
||||
dev->gso_min_segs = NIC_MIN_PHYS_BUF_COUNT;
|
||||
#endif //LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)
|
||||
#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
|
||||
#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)
|
||||
#endif //NV_NETIF_SET_TSO_MAX_SIZE_PRESENT
|
||||
} else {
|
||||
dev->hw_features |= NETIF_F_IPV6_CSUM;
|
||||
dev->features |= NETIF_F_IPV6_CSUM;
|
||||
@@ -27090,10 +27092,10 @@ rtl8168_init_one(struct pci_dev *pdev,
|
||||
dev->hw_features |= NETIF_F_TSO6;
|
||||
//dev->features |= NETIF_F_TSO6;
|
||||
}
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)
|
||||
#if defined(NV_NETIF_SET_TSO_MAX_SIZE_PRESENT) /* Linux v5.19 */
|
||||
netif_set_tso_max_size(dev, LSO_64K);
|
||||
netif_set_tso_max_segs(dev, NIC_MAX_PHYS_BUF_COUNT_LSO2);
|
||||
#else //LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)
|
||||
#else //NV_NETIF_SET_TSO_MAX_SIZE_PRESENT
|
||||
netif_set_gso_max_size(dev, LSO_64K);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
|
||||
dev->gso_max_segs = NIC_MAX_PHYS_BUF_COUNT_LSO2;
|
||||
@@ -27101,7 +27103,7 @@ rtl8168_init_one(struct pci_dev *pdev,
|
||||
dev->gso_min_segs = NIC_MIN_PHYS_BUF_COUNT;
|
||||
#endif //LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)
|
||||
#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
|
||||
#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)
|
||||
#endif //NV_NETIF_SET_TSO_MAX_SIZE_PRESENT
|
||||
}
|
||||
#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
|
||||
#endif //LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
|
||||
|
||||
@@ -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 ?=
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user