From 43ecc8a21a6a6f44111c60f18059afb67822920a Mon Sep 17 00:00:00 2001 From: Xiaoyu Li Date: Tue, 8 Aug 2023 10:23:48 +0800 Subject: [PATCH] compat: add compat code for ANOLIS 8.6 Since ANOLIS 8.6 contains a 4.18 kernel variant as option, some compat codes are needed to ensure nfp can be compiled successfully against this kernel. This compat patch is mainly used for ANOLIS 8.6. But also for other version of ANOLIS 8.8 and ANOLIS 7.9. Signed-off-by: Xiaoyu Li Signed-off-by: Louis Peens --- src/nfp_devlink.c | 18 ++++++++++++------ src/nfpcore/kcompat.h | 7 +++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/nfp_devlink.c b/src/nfp_devlink.c index e6ac96f7..5288e027 100644 --- a/src/nfp_devlink.c +++ b/src/nfp_devlink.c @@ -31,7 +31,8 @@ nfp_devlink_fill_eth_port(struct nfp_port *port, static int #if VER_NON_RHEL_LT(5, 18) || \ (RHEL_RELEASE_GE(9, 0, 0, 0) && RHEL_RELEASE_LT(9, 163, 0, 0)) || \ - RHEL_RELEASE_LT(8, 425, 0, 0) + (RHEL_RELEASE_LT(8, 425, 0, 0) && !COMPAT_ANOLISLINUX) || \ + ANOLIS_RELEASE_LT(8, 425, 10, 1) nfp_devlink_fill_eth_port_from_id(struct nfp_pf *pf, unsigned int port_index, #else nfp_devlink_fill_eth_port_from_id(struct nfp_pf *pf, @@ -43,7 +44,8 @@ nfp_devlink_fill_eth_port_from_id(struct nfp_pf *pf, #if VER_NON_RHEL_LT(5, 18) || \ (RHEL_RELEASE_GE(9, 0, 0, 0) && RHEL_RELEASE_LT(9, 163, 0, 0)) || \ - RHEL_RELEASE_LT(8, 425, 0, 0) + (RHEL_RELEASE_LT(8, 425, 0, 0) && !COMPAT_ANOLISLINUX) || \ + ANOLIS_RELEASE_LT(8, 425, 10, 1) port = nfp_port_from_id(pf, NFP_PORT_PHYS_PORT, port_index); #else port = container_of(dl_port, struct nfp_port, dl_port); @@ -83,7 +85,8 @@ nfp_devlink_port_split(struct devlink *devlink, unsigned int port_index, unsigned int count) #elif VER_NON_RHEL_LT(5, 18) || \ (RHEL_RELEASE_GE(9, 0, 0, 0) && RHEL_RELEASE_LT(9, 163, 0, 0)) || \ - RHEL_RELEASE_LT(8, 425, 0, 0) + (RHEL_RELEASE_LT(8, 425, 0, 0) && !COMPAT_ANOLISLINUX) || \ + ANOLIS_RELEASE_LT(8, 425, 10, 1) nfp_devlink_port_split(struct devlink *devlink, unsigned int port_index, unsigned int count, struct netlink_ext_ack *extack) #else @@ -106,7 +109,8 @@ nfp_devlink_port_split(struct devlink *devlink, struct devlink_port *port, rtnl_lock(); #if VER_NON_RHEL_LT(5, 18) || \ (RHEL_RELEASE_GE(9, 0, 0, 0) && RHEL_RELEASE_LT(9, 163, 0, 0)) || \ - RHEL_RELEASE_LT(8, 425, 0, 0) + (RHEL_RELEASE_LT(8, 425, 0, 0) && !COMPAT_ANOLISLINUX) || \ + ANOLIS_RELEASE_LT(8, 425, 10, 1) ret = nfp_devlink_fill_eth_port_from_id(pf, port_index, ð_port); #else ret = nfp_devlink_fill_eth_port_from_id(pf, port, ð_port); @@ -139,7 +143,8 @@ static int nfp_devlink_port_unsplit(struct devlink *devlink, unsigned int port_index) #elif VER_NON_RHEL_LT(5, 18) || \ (RHEL_RELEASE_GE(9, 0, 0, 0) && RHEL_RELEASE_LT(9, 163, 0, 0)) || \ - RHEL_RELEASE_LT(8, 425, 0, 0) + (RHEL_RELEASE_LT(8, 425, 0, 0) && !COMPAT_ANOLISLINUX) || \ + ANOLIS_RELEASE_LT(8, 425, 10, 1) nfp_devlink_port_unsplit(struct devlink *devlink, unsigned int port_index, struct netlink_ext_ack *extack) #else @@ -159,7 +164,8 @@ nfp_devlink_port_unsplit(struct devlink *devlink, struct devlink_port *port, rtnl_lock(); #if VER_NON_RHEL_LT(5, 18) || \ (RHEL_RELEASE_GE(9, 0, 0, 0) && RHEL_RELEASE_LT(9, 163, 0, 0)) || \ - RHEL_RELEASE_LT(8, 425, 0, 0) + (RHEL_RELEASE_LT(8, 425, 0, 0) && !COMPAT_ANOLISLINUX) || \ + ANOLIS_RELEASE_LT(8, 425, 10, 1) ret = nfp_devlink_fill_eth_port_from_id(pf, port_index, ð_port); #else ret = nfp_devlink_fill_eth_port_from_id(pf, port, ð_port); diff --git a/src/nfpcore/kcompat.h b/src/nfpcore/kcompat.h index f69c03bd..4face541 100644 --- a/src/nfpcore/kcompat.h +++ b/src/nfpcore/kcompat.h @@ -117,6 +117,13 @@ #define VER_ANOLISL_LT(x, y) (COMPAT_ANOLISLINUX && VER_KERN_LT(x, y)) #define VER_ANOLISL_EQ(x, y) (COMPAT_ANOLISLINUX && VER_KERN_EQ(x, y)) +#define ANOLIS_RELEASE_LT(r, x, y, z)\ + (COMPAT_ANOLISLINUX && (VER_RHEL_LT(r, 0) || RHEL_MAJOR_EQ(r) && \ + RHEL_RELEASE_EXTRACT < RHEL_RELEASE_MERGE(x, y, z))) +#define ANOLIS_RELEASE_GE(r, x, y, z)\ + (COMPAT_ANOLISLINUX && (VER_RHEL_GE(r+1, 0) || (RHEL_MAJOR_EQ(r) && \ + RHEL_RELEASE_EXTRACT >= RHEL_RELEASE_MERGE(x, y, z)))) + #define RHEL_RELEASE_MERGE(a, b, c) (((a) << 16) + ((b) << 8) + (c)) #define RHEL_RELEASE_EXTRACT\ RHEL_RELEASE_MERGE(RHEL_RELEASE_EXTRACT_X, RHEL_RELEASE_EXTRACT_Y, RHEL_RELEASE_EXTRACT_Z)