Skip to content

Commit 14b9b67

Browse files
committed
mctp-bench: Use MCTP vendor defined message type
mctp-bench now uses a distinct message type instead of PLDM. Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
1 parent 01eb800 commit 14b9b67

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/mctp-bench.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@
1515

1616
#include "mctp.h"
1717

18+
// Code Construct allocation
19+
static const uint8_t VENDOR_TYPE_BENCH[3] = { 0xcc, 0xde, 0xf1 };
20+
static const uint8_t MCTP_TYPE_VENDOR_PCIE = 0x7e;
21+
1822
struct mctp_bench_send_args {
1923
mctp_eid_t eid;
2024
size_t len;
2125
int net;
2226
};
2327

2428
struct msg_header {
29+
uint8_t vendor_prefix[sizeof(VENDOR_TYPE_BENCH)];
2530
uint16_t magic;
2631
uint32_t seq_no;
27-
};
32+
} __attribute__((packed));
2833

2934
struct mctp_stats {
3035
size_t total_received_len, curr_packet_len;
@@ -116,6 +121,12 @@ static int handle_incoming_msg(struct recv_ctx *recv_ctx)
116121
}
117122

118123
hdr = (struct msg_header *)recv_ctx->buf;
124+
if (memcmp(hdr->vendor_prefix, VENDOR_TYPE_BENCH, sizeof(VENDOR_TYPE_BENCH)) != 0) {
125+
warnx("recv: unexpected vendor prefix %02x %02x %02x",
126+
hdr->vendor_prefix[0], hdr->vendor_prefix[1], hdr->vendor_prefix[2]
127+
);
128+
return -1;
129+
}
119130
if (hdr->magic != MAGIC_VAL) {
120131
warnx("recv: expected magic:\"%x\", got:\"%x\"\n", MAGIC_VAL,
121132
hdr->magic);
@@ -158,7 +169,7 @@ static int mctp_bench_recv()
158169
addr.smctp_family = AF_MCTP;
159170
addr.smctp_network = MCTP_NET_ANY;
160171
addr.smctp_addr.s_addr = MCTP_ADDR_ANY;
161-
addr.smctp_type = 1;
172+
addr.smctp_type = MCTP_TYPE_VENDOR_PCIE;
162173
addr.smctp_tag = MCTP_TAG_OWNER;
163174

164175
recv_ctx.buf = malloc(MAX_LEN);
@@ -283,7 +294,7 @@ static int mctp_bench_send(struct mctp_bench_send_args send_args)
283294
addr.smctp_family = AF_MCTP;
284295
addr.smctp_network = send_args.net;
285296
addr.smctp_addr.s_addr = send_args.eid;
286-
addr.smctp_type = 1;
297+
addr.smctp_type = MCTP_TYPE_VENDOR_PCIE;
287298
printf("send: eid = %d, net = %d, type = %d, msg_len = %zu bytes\n",
288299
send_args.eid, send_args.net, addr.smctp_type, send_args.len);
289300

0 commit comments

Comments
 (0)