diff options
author | jhb <jhb@FreeBSD.org> | 2016-12-05 23:02:26 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2016-12-05 23:02:26 +0000 |
commit | e30b23b3bc230b0a10e04b086d44428ad4ca9d13 (patch) | |
tree | dc1cf08626b21f8e69ed41541160033844ef1726 /tools | |
parent | fbf49236ec1ddc1c50b5f7213a85cfb3e6ea5e2d (diff) | |
download | FreeBSD-src-e30b23b3bc230b0a10e04b086d44428ad4ca9d13.zip FreeBSD-src-e30b23b3bc230b0a10e04b086d44428ad4ca9d13.tar.gz |
MFC 306821,306823: Permit updating firmware config file in flash.
306821:
cxgbe(4): Add an ioctl to copy a firmware config file to the card's flash.
306823:
cxgbetool: Add a loadcfg subcommand to allow a user to upload a firmware
configuration file to the card.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/cxgbetool/cxgbetool.8 | 13 | ||||
-rw-r--r-- | tools/tools/cxgbetool/cxgbetool.c | 47 |
2 files changed, 60 insertions, 0 deletions
diff --git a/tools/tools/cxgbetool/cxgbetool.8 b/tools/tools/cxgbetool/cxgbetool.8 index 16b0ce6..bdc4eb7 100644 --- a/tools/tools/cxgbetool/cxgbetool.8 +++ b/tools/tools/cxgbetool/cxgbetool.8 @@ -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 diff --git a/tools/tools/cxgbetool/cxgbetool.c b/tools/tools/cxgbetool/cxgbetool.c index 7d9a4c9..71f07df 100644 --- a/tools/tools/cxgbetool/cxgbetool.c +++ b/tools/tools/cxgbetool/cxgbetool.c @@ -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" @@ -1835,6 +1837,49 @@ loadfw(int argc, const char *argv[]) } 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)) { int rc; @@ -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); |