Skip to content

Commit b07041b

Browse files
chorkinigaw
authored andcommitted
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 <[email protected]>
1 parent e37a51a commit b07041b

1 file changed

Lines changed: 29 additions & 20 deletions

File tree

src/nvme/mi-mctp.c

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,35 @@ struct sockaddr_mctp {
7676

7777
#endif /* !AF_MCTP */
7878

79+
#if !defined(MCTP_TAG_PREALLOC)
80+
/*Adding this here for users with older build MCTP header
81+
*that require SIOCMCTPALLOC/DROP
82+
*/
83+
#define MCTP_TAG_PREALLOC 0x10
84+
85+
#define SIOCMCTPALLOCTAG (SIOCPROTOPRIVATE + 0)
86+
#define SIOCMCTPDROPTAG (SIOCPROTOPRIVATE + 1)
87+
88+
/* Deprecated: use mctp_ioc_tag_ctl2 / TAG2 ioctls instead, which defines the
89+
* MCTP network ID as part of the allocated tag. Using this assumes the default
90+
* net ID for allocated tags, which may not give correct behaviour on system
91+
* with multiple networks configured.
92+
*/
93+
struct mctp_ioc_tag_ctl {
94+
mctp_eid_t peer_addr;
95+
96+
/* For SIOCMCTPALLOCTAG: must be passed as zero, kernel will
97+
* populate with the allocated tag value. Returned tag value will
98+
* always have TO and PREALLOC set.
99+
*
100+
* For SIOCMCTPDROPTAG: userspace provides tag value to drop, from
101+
* a prior SIOCMCTPALLOCTAG call (and so must have TO and PREALLOC set).
102+
*/
103+
__u8 tag;
104+
__u16 flags;
105+
};
106+
#endif /* !MCTP_TAG_PREALLOC */
107+
79108
#define MCTP_TYPE_NVME 0x04
80109
#define MCTP_TYPE_MIC 0x80
81110

@@ -149,7 +178,6 @@ void __nvme_mi_mctp_set_ops(const struct __mi_mctp_socket_ops *newops)
149178
}
150179
static const struct nvme_mi_transport nvme_mi_transport_mctp;
151180

152-
#ifdef SIOCMCTPALLOCTAG
153181
static __u8 nvme_mi_mctp_tag_alloc(struct nvme_mi_ep *ep)
154182
{
155183
struct nvme_mi_transport_mctp *mctp;
@@ -193,25 +221,6 @@ static void nvme_mi_mctp_tag_drop(struct nvme_mi_ep *ep, __u8 tag)
193221
ops.ioctl_tag(mctp->sd, SIOCMCTPDROPTAG, &ctl);
194222
}
195223

196-
#else /* !defined SIOMCTPTAGALLOC */
197-
198-
static __u8 nvme_mi_mctp_tag_alloc(struct nvme_mi_ep *ep)
199-
{
200-
static bool logged;
201-
if (!logged) {
202-
nvme_msg(ep->root, LOG_INFO,
203-
"Build does not support explicit tag allocation\n");
204-
logged = true;
205-
}
206-
return MCTP_TAG_OWNER;
207-
}
208-
209-
static void nvme_mi_mctp_tag_drop(struct nvme_mi_ep *ep, __u8 tag)
210-
{
211-
}
212-
213-
#endif /* !defined SIOMCTPTAGALLOC */
214-
215224
struct nvme_mi_msg_resp_mpr {
216225
struct nvme_mi_msg_hdr hdr;
217226
__u8 status;

0 commit comments

Comments
 (0)