diff --git a/src/nvme/mi-mctp-compat.h b/src/nvme/mi-mctp-compat.h new file mode 100644 index 000000000..b6427dda0 --- /dev/null +++ b/src/nvme/mi-mctp-compat.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#ifndef _MI_MCTP_COMPAT_H +#define _MI_MCTP_COMPAT_H + +#include + +/* As of kernel v5.15, these AF_MCTP-related definitions are provided by + * linux/mctp.h. However, we provide a set here while that header percolates + * through to standard includes. + * + * These were all introduced in the same version as AF_MCTP was defined, + * so we can key off the presence of that. + */ + +typedef __u8 mctp_eid_t; + +struct mctp_addr { + mctp_eid_t s_addr; +}; + +struct sockaddr_mctp { + unsigned short int smctp_family; + __u16 __smctp_pad0; + unsigned int smctp_network; + struct mctp_addr smctp_addr; + __u8 smctp_type; + __u8 smctp_tag; + __u8 __smctp_pad1; +}; + +#define MCTP_NET_ANY 0x0 + +#define MCTP_ADDR_NULL 0x00 +#define MCTP_ADDR_ANY 0xff + +#define MCTP_TAG_MASK 0x07 +#define MCTP_TAG_OWNER 0x08 + +#endif /* _MI_MCTP_COMPAT_H */ diff --git a/src/nvme/mi-mctp.c b/src/nvme/mi-mctp.c index a66e4c7b3..187d4a190 100644 --- a/src/nvme/mi-mctp.c +++ b/src/nvme/mi-mctp.c @@ -20,6 +20,8 @@ #if HAVE_LINUX_MCTP_H #include +#else +#include "nvme/mi-mctp-compat.h" #endif #include @@ -41,41 +43,6 @@ #define AF_MCTP 45 #endif -#if !HAVE_LINUX_MCTP_H -/* As of kernel v5.15, these AF_MCTP-related definitions are provided by - * linux/mctp.h. However, we provide a set here while that header percolates - * through to standard includes. - * - * These were all introduced in the same version as AF_MCTP was defined, - * so we can key off the presence of that. - */ - -typedef __u8 mctp_eid_t; - -struct mctp_addr { - mctp_eid_t s_addr; -}; - -struct sockaddr_mctp { - unsigned short int smctp_family; - __u16 __smctp_pad0; - unsigned int smctp_network; - struct mctp_addr smctp_addr; - __u8 smctp_type; - __u8 smctp_tag; - __u8 __smctp_pad1; -}; - -#define MCTP_NET_ANY 0x0 - -#define MCTP_ADDR_NULL 0x00 -#define MCTP_ADDR_ANY 0xff - -#define MCTP_TAG_MASK 0x07 -#define MCTP_TAG_OWNER 0x08 - -#endif /* !AF_MCTP */ - #if !defined(MCTP_TAG_PREALLOC) /*Adding this here for users with older build MCTP header *that require SIOCMCTPALLOC/DROP diff --git a/test/mi-mctp.c b/test/mi-mctp.c index 7d1acd2c6..2a6e1f04c 100644 --- a/test/mi-mctp.c +++ b/test/mi-mctp.c @@ -22,6 +22,12 @@ #include "nvme/private.h" #include "utils.h" +#if HAVE_LINUX_MCTP_H +#include +#else +#include "nvme/mi-mctp-compat.h" +#endif + /* 4096 byte max MCTP message, plus space for header data */ #define MAX_BUFSIZ 8192