From b7509072f51d43f49163075bbaf7c3f9d225c5e5 Mon Sep 17 00:00:00 2001 From: Chuck Horkin Date: Fri, 30 May 2025 16:32:18 +0000 Subject: [PATCH] mi: Additional define options for older systems with SIOCMCTPALLOC Older systems (WSL for example) may not include SIOCMCTPALLOC defines and structs and when enabling in MCTP code will cause build errors. This is a workaround. Signed-off-by: Chuck Horkin --- src/nvme/mi-mctp.c | 49 +++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/nvme/mi-mctp.c b/src/nvme/mi-mctp.c index 308e061b0..a66e4c7b3 100644 --- a/src/nvme/mi-mctp.c +++ b/src/nvme/mi-mctp.c @@ -76,6 +76,35 @@ struct sockaddr_mctp { #endif /* !AF_MCTP */ +#if !defined(MCTP_TAG_PREALLOC) +/*Adding this here for users with older build MCTP header + *that require SIOCMCTPALLOC/DROP + */ +#define MCTP_TAG_PREALLOC 0x10 + +#define SIOCMCTPALLOCTAG (SIOCPROTOPRIVATE + 0) +#define SIOCMCTPDROPTAG (SIOCPROTOPRIVATE + 1) + +/* Deprecated: use mctp_ioc_tag_ctl2 / TAG2 ioctls instead, which defines the + * MCTP network ID as part of the allocated tag. Using this assumes the default + * net ID for allocated tags, which may not give correct behaviour on system + * with multiple networks configured. + */ +struct mctp_ioc_tag_ctl { + mctp_eid_t peer_addr; + + /* For SIOCMCTPALLOCTAG: must be passed as zero, kernel will + * populate with the allocated tag value. Returned tag value will + * always have TO and PREALLOC set. + * + * For SIOCMCTPDROPTAG: userspace provides tag value to drop, from + * a prior SIOCMCTPALLOCTAG call (and so must have TO and PREALLOC set). + */ + __u8 tag; + __u16 flags; +}; +#endif /* !MCTP_TAG_PREALLOC */ + #define MCTP_TYPE_NVME 0x04 #define MCTP_TYPE_MIC 0x80 @@ -149,7 +178,6 @@ void __nvme_mi_mctp_set_ops(const struct __mi_mctp_socket_ops *newops) } static const struct nvme_mi_transport nvme_mi_transport_mctp; -#ifdef SIOCMCTPALLOCTAG static __u8 nvme_mi_mctp_tag_alloc(struct nvme_mi_ep *ep) { struct nvme_mi_transport_mctp *mctp; @@ -193,25 +221,6 @@ static void nvme_mi_mctp_tag_drop(struct nvme_mi_ep *ep, __u8 tag) ops.ioctl_tag(mctp->sd, SIOCMCTPDROPTAG, &ctl); } -#else /* !defined SIOMCTPTAGALLOC */ - -static __u8 nvme_mi_mctp_tag_alloc(struct nvme_mi_ep *ep) -{ - static bool logged; - if (!logged) { - nvme_msg(ep->root, LOG_INFO, - "Build does not support explicit tag allocation\n"); - logged = true; - } - return MCTP_TAG_OWNER; -} - -static void nvme_mi_mctp_tag_drop(struct nvme_mi_ep *ep, __u8 tag) -{ -} - -#endif /* !defined SIOMCTPTAGALLOC */ - struct nvme_mi_msg_resp_mpr { struct nvme_mi_msg_hdr hdr; __u8 status;