Skip to content

Commit

Permalink
compat: add compat code for ANOLIS 8.6
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Louis Peens <[email protected]>
  • Loading branch information
xiaoyu-li-corigine authored and louis-peens committed Aug 15, 2023
1 parent 448d5e7 commit 43ecc8a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/nfp_devlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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, &eth_port);
#else
ret = nfp_devlink_fill_eth_port_from_id(pf, port, &eth_port);
Expand Down Expand Up @@ -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
Expand All @@ -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, &eth_port);
#else
ret = nfp_devlink_fill_eth_port_from_id(pf, port, &eth_port);
Expand Down
7 changes: 7 additions & 0 deletions src/nfpcore/kcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 43ecc8a

Please sign in to comment.