Skip to content

Commit

Permalink
nfp: add compat code for Kylin V10SP3 4.19.90-52.41.v2207
Browse files Browse the repository at this point in the history
The new Kylin kernel revision of 4.19.90-52.41 of V10SP3 introduces
some compatibility issue. To avoid cumbersome parsing of revision
number, use content check for the compat code.

Signed-off-by: Yinjun Zhang <[email protected]>
Signed-off-by: Louis Peens <[email protected]>
  • Loading branch information
Yinjun Zhang authored and louis-peens committed Nov 14, 2024
1 parent d1a0544 commit 02eb7ce
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ $(eval $(call add_compat_flag,$(srctree)/include/net/flow_offload.h,_NET_FLOW_OF
# Check for bpf_mac_inc type
$(eval $(call add_compat_flag,$(srctree)/include/linux/bpf.h,"^void bpf_map_inc(struct bpf_map \*map);",COMPAT__VOID_BPF_MAP_INC))

# Check for udp_tunnel_nic_add/del_port
$(eval $(call add_compat_flag,$(srctree)/include/net/udp_tunnel.h,"udp_tunnel_nic_add_port",COMPAT__UDP_TUN_NIC_PORT))

utsrelease_h_path :=$(srctree)/include/generated/utsrelease.h
# Check for BC Linux
$(eval $(call add_compat_flag,$(utsrelease_h_path),bclinux,COMPAT_BCLINUX=1))
Expand Down
10 changes: 4 additions & 6 deletions src/nfp_net_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,7 @@ static int nfp_net_set_config_and_enable(struct nfp_net *nn)
nn->dp.ctrl = new_ctrl;
}

#if COMPAT__HAVE_VXLAN_OFFLOAD && (VER_NON_RHEL_OR_KYL_LT(5, 9) || VER_RHEL_LT(8, 4) \
|| VER_KYL_LT(10, 4))
#if COMPAT__HAVE_VXLAN_OFFLOAD && !defined(COMPAT__UDP_TUN_NIC_PORT)
/* Since reconfiguration requests while NFP is down are ignored we
* have to wipe the entire VXLAN configuration and reinitialize it.
*/
Expand Down Expand Up @@ -2354,8 +2353,7 @@ nfp_net_get_phys_port_name(struct net_device *netdev, char *name, size_t len)
}
#endif

#if COMPAT__HAVE_VXLAN_OFFLOAD && (VER_NON_RHEL_OR_SLEL_LT(5, 9) || \
VER_RHEL_LT(8, 4) || SLEL_LOCALVER_LT(5, 3, 18, 57, 0))
#if COMPAT__HAVE_VXLAN_OFFLOAD && !defined(COMPAT__UDP_TUN_NIC_PORT)
/**
* nfp_net_set_vxlan_port() - set vxlan port in SW and reconfigure HW
* @nn: NFP Net device to reconfigure
Expand Down Expand Up @@ -2835,7 +2833,7 @@ const struct net_device_ops nfp_nfdk_netdev_ops = {
#endif
};

#if VER_NON_RHEL_OR_KYL_GE(5, 9) || VER_RHEL_GE(8, 4) || VER_KYL_GE(10, 4)
#ifdef COMPAT__UDP_TUN_NIC_PORT
static int nfp_udp_tunnel_sync(struct net_device *netdev, unsigned int table)
{
struct nfp_net *nn = netdev_priv(netdev);
Expand Down Expand Up @@ -3196,7 +3194,7 @@ static void nfp_net_netdev_init(struct nfp_net *nn)
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
#endif
}
#if VER_NON_RHEL_OR_KYL_GE(5, 9) || VER_RHEL_GE(8, 4) || VER_KYL_GE(10, 4)
#ifdef COMPAT__UDP_TUN_NIC_PORT
netdev->udp_tunnel_nic_info = &nfp_udp_tunnels;
#endif
nn->dp.ctrl |= NFP_NET_CFG_CTRL_VXLAN;
Expand Down
3 changes: 1 addition & 2 deletions src/nfp_net_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -1552,8 +1552,7 @@ flow_indr_block_cb_remove(struct flow_block_cb *block_cb,
}
#endif

#if COMPAT__HAVE_UDP_OFFLOAD && ((!COMPAT_SLELINUX && VER_NON_RHEL_OR_KYL_LT(5, 9)) || \
VER_RHEL_LT(8, 4) || VER_KYL_LT(10, 4) || SLEL_LOCALVER_LT(5, 3, 18, 57, 0))
#if COMPAT__HAVE_UDP_OFFLOAD && !defined(COMPAT__UDP_TUN_NIC_PORT)
#define udp_tunnel_nic_add_port nfp_net_add_vxlan_port
#define udp_tunnel_nic_del_port nfp_net_del_vxlan_port
#endif
Expand Down
6 changes: 4 additions & 2 deletions src/nfpcore/kcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -1063,11 +1063,13 @@ static inline u64 pci_get_dsn(struct pci_dev *dev)
#undef CONFIG_NFP_APP_FLOWER
#endif

#if VER_NON_RHEL_LT(5, 3) || VER_RHEL_LT(8, 2)
#include <linux/inetdevice.h>
#ifndef in_dev_for_each_ifa_rtnl
#define in_dev_for_each_ifa_rtnl(ifa, in_dev) \
for (ifa = rtnl_dereference((in_dev)->ifa_list); ifa; \
ifa = rtnl_dereference(ifa->ifa_next))

#endif
#ifndef in_dev_for_each_ifa_rcu
#define in_dev_for_each_ifa_rcu(ifa, in_dev) \
for (ifa = rcu_dereference((in_dev)->ifa_list); ifa; \
ifa = rcu_dereference(ifa->ifa_next))
Expand Down

0 comments on commit 02eb7ce

Please sign in to comment.