Add the ability to query the EEPROM information in mlx5tool(8).
Submitted by: slavash@ MFC after: 3 days Sponsored by: Mellanox Technologies
This commit is contained in:
parent
74ef689370
commit
b00ae50aae
@ -30,28 +30,31 @@
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm mlx5tool
|
||||
.Nd Utility for managing Connect-X 4/5 Mellanox network adapters
|
||||
.Nd Utility for managing Connect-X 4/5/6 Mellanox network adapters
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Fl d Ar domain:bus:slot:func
|
||||
.Fl E
|
||||
.Nm
|
||||
.Fl d Ar domain:bus:slot:func
|
||||
.Fl e
|
||||
.Nm
|
||||
.Fl d Ar domain:bus:slot:func
|
||||
.Fl rn
|
||||
.Fl f Ar file.mfa2
|
||||
.Nm
|
||||
.Fl d Ar domain:bus:slot:func
|
||||
.Fl o Ar file
|
||||
.Fl w
|
||||
.Nm
|
||||
.Fl d Ar domain:bus:slot:func
|
||||
.Fl f Ar file.mfa2
|
||||
.Fl r
|
||||
.Nm
|
||||
.Fl d Ar domain:bus:slot:func
|
||||
.Fl z
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility is provided for management of the Connect-X 4 and 5 network adapters
|
||||
utility is provided for management of the Connect-X4, 5 and 6 network adapters
|
||||
in the aspects not covered by the generic
|
||||
.Xr ifconfig 8
|
||||
command, mostly related to the PCIe attachment and internal card working.
|
||||
@ -73,21 +76,13 @@ analysis of the failure by the Mellanox support team.
|
||||
.Pp
|
||||
The following commands are currently implemented:
|
||||
.Bl -tag -width indent
|
||||
.It Fl E
|
||||
Print EEPROM information
|
||||
.It Fl e
|
||||
Take the snapshot of the firmware registers state and store it in the
|
||||
kernel buffer.
|
||||
The buffer must be empty, in other words, no dumps should be written so
|
||||
far, or existing dump cleared with the
|
||||
.Fl r
|
||||
command for the specified device.
|
||||
.It Fl r
|
||||
Clear the stored firmware dump, preparing the kernel buffer for
|
||||
the next dump.
|
||||
.It Fl w
|
||||
Fetches the stored firmware dump and writes it into the file specified
|
||||
by the
|
||||
.Fl o
|
||||
option argument.
|
||||
.It Fl f
|
||||
Flashes the firmware image
|
||||
.Fa file.mfa2
|
||||
@ -100,6 +95,16 @@ newly flashed image, which can be performed by the system reboot
|
||||
or using the
|
||||
.Fl z
|
||||
option.
|
||||
.Fl r
|
||||
command for the specified device.
|
||||
.It Fl r
|
||||
Clear the stored firmware dump, preparing the kernel buffer for
|
||||
the next dump.
|
||||
.It Fl w
|
||||
Fetches the stored firmware dump and writes it into the file specified
|
||||
by the
|
||||
.Fl o
|
||||
option argument.
|
||||
.It Fl z
|
||||
Performs PCIe link-level reset on the specified device.
|
||||
.El
|
||||
|
@ -200,6 +200,85 @@ mlx5tool_fw_reset(int ctldev, const struct mlx5_tool_addr *addr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#define MLX5_EEPROM_HIGH_PAGE_OFFSET 128
|
||||
#define MLX5_EEPROM_PAGE_LENGTH 256
|
||||
|
||||
static void
|
||||
mlx5tool_eeprom_print(struct mlx5_eeprom_get *eeprom_info)
|
||||
{
|
||||
unsigned int byte_to_write, index_in_row, line_length, row;
|
||||
|
||||
byte_to_write = 0;
|
||||
line_length = 16;
|
||||
|
||||
printf("\nOffset\t\tValues\n");
|
||||
printf("------\t\t------");
|
||||
while (byte_to_write < eeprom_info->eeprom_info_out_len) {
|
||||
printf("\n0x%04X\t\t", byte_to_write);
|
||||
for (index_in_row = 0; index_in_row < line_length;
|
||||
index_in_row++) {
|
||||
printf("%02X ",
|
||||
((uint8_t *)eeprom_info->eeprom_info_buf)[
|
||||
byte_to_write]);
|
||||
byte_to_write++;
|
||||
}
|
||||
}
|
||||
|
||||
if (eeprom_info->eeprom_info_page_valid) {
|
||||
row = MLX5_EEPROM_HIGH_PAGE_OFFSET;
|
||||
printf("\n\nUpper Page 0x03\n");
|
||||
printf("\nOffset\t\tValues\n");
|
||||
printf("------\t\t------");
|
||||
for (row = MLX5_EEPROM_HIGH_PAGE_OFFSET;
|
||||
row < MLX5_EEPROM_PAGE_LENGTH;) {
|
||||
printf("\n0x%04X\t\t", row);
|
||||
for (index_in_row = 0;
|
||||
index_in_row < line_length;
|
||||
index_in_row++) {
|
||||
printf("%02X ",
|
||||
((uint8_t *)eeprom_info->
|
||||
eeprom_info_buf)[byte_to_write]);
|
||||
byte_to_write++;
|
||||
row++;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static int
|
||||
mlx5tool_get_eeprom_info(int ctldev, const struct mlx5_tool_addr *addr)
|
||||
{
|
||||
struct mlx5_eeprom_get eeprom_info;
|
||||
int error;
|
||||
|
||||
memset(&eeprom_info, 0, sizeof(eeprom_info));
|
||||
eeprom_info.devaddr = *addr;
|
||||
|
||||
error = ioctl(ctldev, MLX5_EEPROM_GET, &eeprom_info);
|
||||
if (error != 0) {
|
||||
warn("MLX5_EEPROM_GET");
|
||||
return (error);
|
||||
}
|
||||
eeprom_info.eeprom_info_buf =
|
||||
malloc(eeprom_info.eeprom_info_out_len + MLX5_EEPROM_PAGE_LENGTH);
|
||||
if (eeprom_info.eeprom_info_buf == NULL) {
|
||||
warn("alloc eeprom_info.eeprom_info_buf ");
|
||||
return (ENOMEM);
|
||||
}
|
||||
error = ioctl(ctldev, MLX5_EEPROM_GET, &eeprom_info);
|
||||
if (error != 0) {
|
||||
warn("MLX5_EEPROM_GET");
|
||||
free(eeprom_info.eeprom_info_buf);
|
||||
return (error);
|
||||
}
|
||||
|
||||
mlx5tool_eeprom_print(&eeprom_info);
|
||||
|
||||
free(eeprom_info.eeprom_info_buf);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
@ -209,6 +288,7 @@ usage(void)
|
||||
" -e | -f fw.mfa2 | -z]\n");
|
||||
fprintf(stderr, "\t-w - write firmware dump to the specified file\n");
|
||||
fprintf(stderr, "\t-r - reset dump\n");
|
||||
fprintf(stderr, "\t-E - get eeprom info\n");
|
||||
fprintf(stderr, "\t-e - force dump\n");
|
||||
fprintf(stderr, "\t-f fw.img - flash firmware from fw.img\n");
|
||||
fprintf(stderr, "\t-z - initiate firmware reset\n");
|
||||
@ -221,6 +301,7 @@ enum mlx5_action {
|
||||
ACTION_DUMP_FORCE,
|
||||
ACTION_FW_UPDATE,
|
||||
ACTION_FW_RESET,
|
||||
ACTION_GET_EEPROM_INFO,
|
||||
ACTION_NONE,
|
||||
};
|
||||
|
||||
@ -238,7 +319,7 @@ main(int argc, char *argv[])
|
||||
addrstr = NULL;
|
||||
dumpname = NULL;
|
||||
img_fw_path = NULL;
|
||||
while ((c = getopt(argc, argv, "d:ef:ho:rwz")) != -1) {
|
||||
while ((c = getopt(argc, argv, "d:Eef:ho:rwz")) != -1) {
|
||||
switch (c) {
|
||||
case 'd':
|
||||
addrstr = optarg;
|
||||
@ -248,6 +329,11 @@ main(int argc, char *argv[])
|
||||
usage();
|
||||
act = ACTION_DUMP_GET;
|
||||
break;
|
||||
case 'E':
|
||||
if (act != ACTION_NONE)
|
||||
usage();
|
||||
act = ACTION_GET_EEPROM_INFO;
|
||||
break;
|
||||
case 'e':
|
||||
if (act != ACTION_NONE)
|
||||
usage();
|
||||
@ -303,6 +389,9 @@ main(int argc, char *argv[])
|
||||
case ACTION_FW_RESET:
|
||||
res = mlx5tool_fw_reset(ctldev, &addr);
|
||||
break;
|
||||
case ACTION_GET_EEPROM_INFO:
|
||||
res = mlx5tool_get_eeprom_info(ctldev, &addr);
|
||||
break;
|
||||
default:
|
||||
res = 0;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user