MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
Format.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Contributors to the Media eXchange Layer project.
2// SPDX-License-Identifier: Apache-2.0
3#include "Format.hpp"
4#include <cstdint>
5#include <string>
6#include <vector>
7#include <rdma/fabric.h>
8
10{
11 std::string interfaceCapsString(std::uint64_t caps)
12 {
13 auto resultLength = std::size_t{0};
14 auto capStrings = std::vector<std::string>{};
16 {
17 resultLength += capStrings.emplace_back("BLOCKING_OPERATIONS").size();
18 }
19 if ((caps & MXL_FABRICS_IFACE_CAP_REMOTE_WRITE) != 0)
20 {
21 resultLength += capStrings.emplace_back("REMOTE_WRITE").size();
22 }
23 if ((caps & MXL_FABRICS_IFACE_CAP_SEND_RECEIVE) != 0)
24 {
25 resultLength += capStrings.emplace_back("SEND_RECEIVE").size();
26 }
27 if (capStrings.empty())
28 {
29 resultLength += capStrings.emplace_back("<none>").size();
30 }
31
32 resultLength += (capStrings.size() - 1); // separating '|' chars
33
34 auto result = capStrings.front();
35 result.reserve(resultLength);
36 for (auto it = capStrings.begin() + 1; it != capStrings.end(); ++it)
37 {
38 result.push_back('|');
39 result.append(*it);
40 }
41
42 return result;
43 }
44
45 std::string fiToString(void* any, ::fi_type type)
46 {
47 auto buf = std::string((type == FI_TYPE_INFO) ? 4096 : 1024, '\0');
48 ::fi_tostr_r(buf.data(), buf.size(), any, type);
49 buf.resize(::strlen(buf.data()));
50 return buf;
51 }
52}
@ MXL_FABRICS_IFACE_CAP_SEND_RECEIVE
Definition fabrics.h:80
@ MXL_FABRICS_IFACE_CAP_BLOCKING_OPERATIONS
Definition fabrics.h:78
@ MXL_FABRICS_IFACE_CAP_REMOTE_WRITE
Definition fabrics.h:79
std::string fiToString(void *any, ::fi_type type)
Definition Format.cpp:45
std::string interfaceCapsString(std::uint64_t caps)
Definition Format.cpp:11