cxgbetool: Add a loadcfg subcommand to allow a user to upload a firmware

configuration file to the card.
This commit is contained in:
Navdeep Parhar 2016-10-07 19:13:29 +00:00
parent 71cc9a9f0e
commit 2099002b62
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=306823
2 changed files with 60 additions and 0 deletions

View File

@ -56,6 +56,10 @@
.It
.Nm Ar nexus Cm i2c Ar port_id devaddr addr Op Ar len
.It
.Nm Ar nexus Cm loadcfg Ar fw-config.txt
.It
.Nm Ar nexus Cm loadcfg clear
.It
.Nm Ar nexus Cm loadfw Ar fw-image.bin
.It
.Nm Ar nexus Cm memdump Ar addr len
@ -353,6 +357,15 @@ Delete filter that is at the given index.
.It Cm filter Cm list
List all filters programmed into the hardware.
.It Cm i2c Ar port_id devaddr addr Op Ar len
.It Cm loadcfg Ar fw-config.txt
Install the firmware configuration file contained in
.Ar fw-config.txt
to the card.
Set hw.cxgbe.config_file="flash" in loader.conf to get
.Xr cxgbe 4
to use the on-flash configuration.
.It Cm loadcfg Cm clear
Erase configuration file from the card.
.It Cm loadfw Ar fw-image.bin
Install the firmware contained in
.Ar fw-image.bin

View File

@ -95,6 +95,8 @@ usage(FILE *fp)
"\tfilter list list all filters\n"
"\tfilter mode [<match>] ... get/set global filter mode\n"
"\ti2c <port> <devaddr> <addr> [<len>] read from i2c device\n"
"\tloadcfg <fw-config.txt> install configuration file\n"
"\tloadcfg clear remove configuration file\n"
"\tloadfw <fw-image.bin> install firmware\n"
"\tmemdump <addr> <len> dump a memory range\n"
"\tmodinfo <port> [raw] optics/cable information\n"
@ -1834,6 +1836,49 @@ loadfw(int argc, const char *argv[])
return (rc);
}
static int
loadcfg(int argc, const char *argv[])
{
int rc, fd;
struct t4_data data = {0};
const char *fname = argv[0];
struct stat st = {0};
if (argc != 1) {
warnx("loadcfg: incorrect number of arguments.");
return (EINVAL);
}
if (strcmp(fname, "clear") == 0)
return (doit(CHELSIO_T4_LOAD_CFG, &data));
fd = open(fname, O_RDONLY);
if (fd < 0) {
warn("open(%s)", fname);
return (errno);
}
if (fstat(fd, &st) < 0) {
warn("fstat");
close(fd);
return (errno);
}
data.len = st.st_size;
data.len &= ~3; /* Clip off to make it a multiple of 4 */
data.data = mmap(0, data.len, PROT_READ, MAP_PRIVATE, fd, 0);
if (data.data == MAP_FAILED) {
warn("mmap");
close(fd);
return (errno);
}
rc = doit(CHELSIO_T4_LOAD_CFG, &data);
munmap(data.data, data.len);
close(fd);
return (rc);
}
static int
read_mem(uint32_t addr, uint32_t len, void (*output)(uint32_t *, uint32_t))
{
@ -2732,6 +2777,8 @@ run_cmd(int argc, const char *argv[])
rc = sched_class(argc, argv);
else if (!strcmp(cmd, "sched-queue"))
rc = sched_queue(argc, argv);
else if (!strcmp(cmd, "loadcfg"))
rc = loadcfg(argc, argv);
else {
rc = EINVAL;
warnx("invalid command \"%s\"", cmd);