mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
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
048ddb58bc
commit
133fc15cf3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=352984
|
@ -30,28 +30,31 @@
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm mlx5tool
|
.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
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Fl d Ar domain:bus:slot:func
|
.Fl d Ar domain:bus:slot:func
|
||||||
|
.Fl E
|
||||||
|
.Nm
|
||||||
|
.Fl d Ar domain:bus:slot:func
|
||||||
.Fl e
|
.Fl e
|
||||||
.Nm
|
.Nm
|
||||||
.Fl d Ar domain:bus:slot:func
|
.Fl d Ar domain:bus:slot:func
|
||||||
.Fl rn
|
.Fl f Ar file.mfa2
|
||||||
.Nm
|
.Nm
|
||||||
.Fl d Ar domain:bus:slot:func
|
.Fl d Ar domain:bus:slot:func
|
||||||
.Fl o Ar file
|
.Fl o Ar file
|
||||||
.Fl w
|
.Fl w
|
||||||
.Nm
|
.Nm
|
||||||
.Fl d Ar domain:bus:slot:func
|
.Fl d Ar domain:bus:slot:func
|
||||||
.Fl f Ar file.mfa2
|
.Fl r
|
||||||
.Nm
|
.Nm
|
||||||
.Fl d Ar domain:bus:slot:func
|
.Fl d Ar domain:bus:slot:func
|
||||||
.Fl z
|
.Fl z
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Nm
|
.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
|
in the aspects not covered by the generic
|
||||||
.Xr ifconfig 8
|
.Xr ifconfig 8
|
||||||
command, mostly related to the PCIe attachment and internal card working.
|
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
|
.Pp
|
||||||
The following commands are currently implemented:
|
The following commands are currently implemented:
|
||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
|
.It Fl E
|
||||||
|
Print EEPROM information
|
||||||
.It Fl e
|
.It Fl e
|
||||||
Take the snapshot of the firmware registers state and store it in the
|
Take the snapshot of the firmware registers state and store it in the
|
||||||
kernel buffer.
|
kernel buffer.
|
||||||
The buffer must be empty, in other words, no dumps should be written so
|
The buffer must be empty, in other words, no dumps should be written so
|
||||||
far, or existing dump cleared with the
|
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
|
.It Fl f
|
||||||
Flashes the firmware image
|
Flashes the firmware image
|
||||||
.Fa file.mfa2
|
.Fa file.mfa2
|
||||||
|
@ -100,6 +95,16 @@ newly flashed image, which can be performed by the system reboot
|
||||||
or using the
|
or using the
|
||||||
.Fl z
|
.Fl z
|
||||||
option.
|
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
|
.It Fl z
|
||||||
Performs PCIe link-level reset on the specified device.
|
Performs PCIe link-level reset on the specified device.
|
||||||
.El
|
.El
|
||||||
|
|
|
@ -200,6 +200,85 @@ mlx5tool_fw_reset(int ctldev, const struct mlx5_tool_addr *addr)
|
||||||
return (0);
|
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
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
@ -209,6 +288,7 @@ usage(void)
|
||||||
" -e | -f fw.mfa2 | -z]\n");
|
" -e | -f fw.mfa2 | -z]\n");
|
||||||
fprintf(stderr, "\t-w - write firmware dump to the specified file\n");
|
fprintf(stderr, "\t-w - write firmware dump to the specified file\n");
|
||||||
fprintf(stderr, "\t-r - reset dump\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-e - force dump\n");
|
||||||
fprintf(stderr, "\t-f fw.img - flash firmware from fw.img\n");
|
fprintf(stderr, "\t-f fw.img - flash firmware from fw.img\n");
|
||||||
fprintf(stderr, "\t-z - initiate firmware reset\n");
|
fprintf(stderr, "\t-z - initiate firmware reset\n");
|
||||||
|
@ -221,6 +301,7 @@ enum mlx5_action {
|
||||||
ACTION_DUMP_FORCE,
|
ACTION_DUMP_FORCE,
|
||||||
ACTION_FW_UPDATE,
|
ACTION_FW_UPDATE,
|
||||||
ACTION_FW_RESET,
|
ACTION_FW_RESET,
|
||||||
|
ACTION_GET_EEPROM_INFO,
|
||||||
ACTION_NONE,
|
ACTION_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -238,7 +319,7 @@ main(int argc, char *argv[])
|
||||||
addrstr = NULL;
|
addrstr = NULL;
|
||||||
dumpname = NULL;
|
dumpname = NULL;
|
||||||
img_fw_path = 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) {
|
switch (c) {
|
||||||
case 'd':
|
case 'd':
|
||||||
addrstr = optarg;
|
addrstr = optarg;
|
||||||
|
@ -248,6 +329,11 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
act = ACTION_DUMP_GET;
|
act = ACTION_DUMP_GET;
|
||||||
break;
|
break;
|
||||||
|
case 'E':
|
||||||
|
if (act != ACTION_NONE)
|
||||||
|
usage();
|
||||||
|
act = ACTION_GET_EEPROM_INFO;
|
||||||
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
if (act != ACTION_NONE)
|
if (act != ACTION_NONE)
|
||||||
usage();
|
usage();
|
||||||
|
@ -303,6 +389,9 @@ main(int argc, char *argv[])
|
||||||
case ACTION_FW_RESET:
|
case ACTION_FW_RESET:
|
||||||
res = mlx5tool_fw_reset(ctldev, &addr);
|
res = mlx5tool_fw_reset(ctldev, &addr);
|
||||||
break;
|
break;
|
||||||
|
case ACTION_GET_EEPROM_INFO:
|
||||||
|
res = mlx5tool_get_eeprom_info(ctldev, &addr);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
res = 0;
|
res = 0;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue