ncsi: Add a NCSI-over-MCTP transport
Add a facility for performing NCSI commands over a NCSI-over-MCTP
interface, alongside the existing Netlink transport.
This adds a new Interface subclass, MCTPInterface, which performs the
MCTP encapsulation/decapsulation, over an AF_MCTP socket.
Tested: able to perform NCSI commands over a MCTP link, to both emulated
and hardware NIC devices. The -m argument can now target a NIC using
MCTP.
For example, sending a raw command to perform a Get Version ID (type
0x15):
root@bmc:~# ncsi-cmd -m 9 --package 0 raw 0x15
<7> Command: type 0x15, payload 0 bytes:
<7> Response 60 bytes: 00 01 00 2b 95 [...]
Change-Id: I9a7bfddfc4fd1b5bb8d0bff187936a0258d3dade
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
diff --git a/src/ncsi_util.hpp b/src/ncsi_util.hpp
index 250c096..27397c8 100644
--- a/src/ncsi_util.hpp
+++ b/src/ncsi_util.hpp
@@ -153,6 +153,20 @@
int ifindex;
};
+struct MCTPInterface : Interface
+{
+ std::optional<NCSIResponse> sendCommand(NCSICommand& cmd);
+ std::string toString();
+
+ MCTPInterface(int net, uint8_t eid);
+ ~MCTPInterface();
+
+ private:
+ int sd;
+ int net;
+ uint8_t eid;
+};
+
} // namespace ncsi
} // namespace network
} // namespace phosphor