How to Find the serial number of Mellanox NIC Adapter in ESXi

송주환·2023년 8월 10일
0

Introudction

Sometimes we need to check the serial number of a NIC for asset management or support requests.
For this purpose, most manufacturers provide the softwares that allow you to check the serial number of your NIC.
Mellanox also provide a software to see the serial number of a device in the Device Manager, when you install the WinOF Driver on Windows, so I assumed that there would be a tool that would provide similar functionality when you install the Mellanox Firmware Tool (MFT).

But I was wrong.

This article will cover a trick to find the serial number of Mellanox NIC without physically detach it from the ESXi Host or remove it from the vDS uplink port.

In Linux Environment

First, I searched how to find the serial number in Linux.
While ESXi is not based on the Linux kernel, the UI/UX is very similar, so it is often easier for third-party vendors to use the Linux implementation.

You can get 'how to find out the serial number of your Mellanox NIC on Linux' at the following links.

The method is simple

  1. Use the command lspci -s -xxxvvv or
  2. After installing MFT, run the command lspci | grep Mellanox | awk '{print $1}' | xargs -i -r mstvpd {}

These two methods worked fine on Linux. But what about ESXi?

In ESXi Environment

There were two problems with applying this method using lspci and mstvpd to ESXi.

First, the lspci command on ESXi does not have a -x option, and the -v option does not produce as verbose output as on Linux.

Second, there is no mstvpd command in the MFT package on ESXi.


Thanks to these small but annoying mistakes!

In ESXi, we can't find the serial number of a NIC using the Mellanox's official method.
So would I have to take the downtime to remove the hardware myself, or pass-through and attach it to a Linux VM?

My ego wouldn't let me leave it at that, and I soon came up with an idea.

Mellanox provides a tools to dump the value of the device's internal registers, so why not use it to get the serial number?

So I put this idea into action.

mstdump Utility

mstdump is a utility that allows you to dump the internal configuration register values of a Mellanox NIC.
An introduction and usage of this utility can be found at the following link.
Although it is usually used for internal debugging, I will use mstdump to get the serial number of the device.

However, there are two prerequisites for this.

First, the serial number of a genuine Mellanox NIC starts with "MT".
Second, the MT must be followed by a number.

Armed with these two pieces of information, we will dump the serial number from the register.

Dump the Serial Number

At first, identify the device whose serial number you want to dump. You should use the mdevices_info tool for this.

Once you have the MST device name to dump the serial number to, enter the following command.

mstdump -full <mst_name> | grep 4d54

In this case, "4d54" is the ASCII code for MT. This is the first gateway to finding the start of the serial number.
This may vary depending on the device and firmware version, but in general, you should see something like this:

We've identified a number of registers that contain 4d54 as a value, but only one of them is the one we're looking for.
Now, let's sequentially convert the values identified above.

The first value starts with an underscore. This is not a serial number, and is probably a board_id value, which can be found in ibv_devinfo command.

The second value is MTCF. This also doesn't fit the format of a serial number, so we pass it by.

The third value is a number, so could this be a serial number? I pulled out the last part to confirm.

Unfortunately, this register address contained the model name.

But what about the next one, 0x4d543136?

BINGO! we have the serial number what we were looking for.
If you know that genuine Mellanox NICs have a serial number of 12 digits, and that 0x20 is a space character in ASCII, you'll be able to find the correct serial number more quickly.

For OEM models, the serial number is formatted differently, but if you know the conventions of the serial number, you can use the same method to find the serial number.

Outro

This way, I was able to extract the serial number without using the official method provided by Mellanox and without having to take any downtime.

I hope this post helps someone else who is struggling with the same issue.

profile
Virtualization / Network / Storage / Server Hardware and.. Linux

0개의 댓글