ncsi: Add Mellanox Get MAC Address handler
This series of patches adds everything necessary to support adding a command handler for Mellanox's OEM NC-SI command "Get MAC Address". The details of this command are proprietary and confidential, but the Linux drivers are open source, and a standardized version of this command is going to be available in NC-SI 1.2.0 as "Get MC MAC Address" (see here).
There's some details on what this "MC MAC Address" is in the 2nd to last patch, "slirp: Add out-of-band ethernet address".
This includes some complicated changes, so I also started adding a test for NC-SI command responses.
I'm very flexible, so let me know what changes I should do to refactor this to make it upstream-able. Ultimately, I'd like to add "mfr-id" and "oob-eth-addr" properties to the QEMU Slirp netdev model that let users configure the simulated netdev manufacturer and provisioned MAC Address so that they can test their BMC Linux NC-SI drivers/software in QEMU.
As a proof of concept, you can take this branch and apply the following diff in QEMU, and then boot an fby3.mtd image [1], and verify that the MAC address gets assigned properly.
diff --git a/net/slirp.c b/net/slirp.c
index 8679be6444..2306c119a7 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -617,7 +617,8 @@ static int net_slirp_init(NetClientState *peer, const char *model,
s = DO_UPCAST(SlirpState, nc, nc);
- cfg.version = SLIRP_CHECK_VERSION(4,7,0) ? 4 : 1;
+ //cfg.version = SLIRP_CHECK_VERSION(4,7,0) ? 4 : 1;
+ cfg.version = 5;
cfg.restricted = restricted;
cfg.in_enabled = ipv4;
cfg.vnetwork = net;
@@ -636,6 +637,9 @@ static int net_slirp_init(NetClientState *peer, const char *model,
cfg.vnameserver6 = ip6_dns;
cfg.vdnssearch = dnssearch;
cfg.vdomainname = vdomainname;
+ cfg.mfr_id = 0x8119;
+ uint8_t oob_eth_addr[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
+ memcpy(cfg.oob_eth_addr, oob_eth_addr, 6);
s->slirp = slirp_new(&cfg, &slirp_cb, s);
QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
qemu-system-arm -machine ast2500-evb -drive file=fby3.mtd,format=raw,if=mtd -nographic \
-netdev user,id=nic,hostfwd=::2222-:22 -net nic,model=ftgmac100,netdev=nic
(user: root
, password: 0penBmc
)
...boot messages...
OpenBMC Release fby3-5066ead400
bmc-oob. login: root
Password:
root@bmc-oob:~# ifconfig
eth0 Link encap:Ethernet HWaddr AA:BB:CC:DD:EE:FF
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fec0::a8bb:ccff:fedd:eeff/64 Scope:Site
inet6 addr: fe80::a8bb:ccff:fedd:eeff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:77 errors:0 dropped:0 overruns:0 frame:0
TX packets:96 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8222 (8.0 KiB) TX bytes:7604 (7.4 KiB)
Interrupt:19
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:240 (240.0 B) TX bytes:240 (240.0 B)
root@bmc-oob:~# ncsi-util -n eth0 -c 0 0x50 0 0 0x81 0x19 0 0 0x1b 0
NC-SI Command Response:
cmd: NCSI_OEM_CMD(0x50)
Response: COMMAND_COMPLETED(0x0000) Reason: NO_ERROR(0x0000)
Payload length = 24
20: 0x00 0x00 0x81 0x19
24: 0x01 0x00 0x1b 0x00
28: 0x00 0x00 0x00 0x00
32: 0xaa 0xbb 0xcc 0xdd
36: 0xee 0xff 0x00 0x00
[1] https://github.com/facebook/openbmc/releases/download/v2021.49.0/fby3.mtd