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.
This commit is contained in:
parent
0eec568592
commit
f6c5ad922b
@ -56,6 +56,7 @@ enum {
|
|||||||
T4_SET_SCHED_QUEUE, /* set queue class */
|
T4_SET_SCHED_QUEUE, /* set queue class */
|
||||||
T4_GET_TRACER, /* get information about a tracer */
|
T4_GET_TRACER, /* get information about a tracer */
|
||||||
T4_SET_TRACER, /* program a tracer */
|
T4_SET_TRACER, /* program a tracer */
|
||||||
|
T4_LOAD_CFG, /* copy a config file to card's flash */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct t4_reg {
|
struct t4_reg {
|
||||||
@ -344,4 +345,5 @@ struct t4_tracer {
|
|||||||
struct t4_sched_queue)
|
struct t4_sched_queue)
|
||||||
#define CHELSIO_T4_GET_TRACER _IOWR('f', T4_GET_TRACER, struct t4_tracer)
|
#define CHELSIO_T4_GET_TRACER _IOWR('f', T4_GET_TRACER, struct t4_tracer)
|
||||||
#define CHELSIO_T4_SET_TRACER _IOW('f', T4_SET_TRACER, struct t4_tracer)
|
#define CHELSIO_T4_SET_TRACER _IOW('f', T4_SET_TRACER, struct t4_tracer)
|
||||||
|
#define CHELSIO_T4_LOAD_CFG _IOW('f', T4_LOAD_CFG, struct t4_data)
|
||||||
#endif
|
#endif
|
||||||
|
@ -549,6 +549,7 @@ static int set_tcb_rpl(struct sge_iq *, const struct rss_header *,
|
|||||||
struct mbuf *);
|
struct mbuf *);
|
||||||
static int get_sge_context(struct adapter *, struct t4_sge_context *);
|
static int get_sge_context(struct adapter *, struct t4_sge_context *);
|
||||||
static int load_fw(struct adapter *, struct t4_data *);
|
static int load_fw(struct adapter *, struct t4_data *);
|
||||||
|
static int load_cfg(struct adapter *, struct t4_data *);
|
||||||
static int read_card_mem(struct adapter *, int, struct t4_mem_range *);
|
static int read_card_mem(struct adapter *, int, struct t4_mem_range *);
|
||||||
static int read_i2c(struct adapter *, struct t4_i2c_data *);
|
static int read_i2c(struct adapter *, struct t4_i2c_data *);
|
||||||
#ifdef TCP_OFFLOAD
|
#ifdef TCP_OFFLOAD
|
||||||
@ -8597,6 +8598,38 @@ done:
|
|||||||
return (rc);
|
return (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
load_cfg(struct adapter *sc, struct t4_data *cfg)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
uint8_t *cfg_data = NULL;
|
||||||
|
|
||||||
|
rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4ldcf");
|
||||||
|
if (rc)
|
||||||
|
return (rc);
|
||||||
|
|
||||||
|
if (cfg->len == 0) {
|
||||||
|
/* clear */
|
||||||
|
rc = -t4_load_cfg(sc, NULL, 0);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg_data = malloc(cfg->len, M_CXGBE, M_WAITOK);
|
||||||
|
if (cfg_data == NULL) {
|
||||||
|
rc = ENOMEM;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = copyin(cfg->data, cfg_data, cfg->len);
|
||||||
|
if (rc == 0)
|
||||||
|
rc = -t4_load_cfg(sc, cfg_data, cfg->len);
|
||||||
|
|
||||||
|
free(cfg_data, M_CXGBE);
|
||||||
|
done:
|
||||||
|
end_synchronized_op(sc, 0);
|
||||||
|
return (rc);
|
||||||
|
}
|
||||||
|
|
||||||
#define MAX_READ_BUF_SIZE (128 * 1024)
|
#define MAX_READ_BUF_SIZE (128 * 1024)
|
||||||
static int
|
static int
|
||||||
read_card_mem(struct adapter *sc, int win, struct t4_mem_range *mr)
|
read_card_mem(struct adapter *sc, int win, struct t4_mem_range *mr)
|
||||||
@ -9154,6 +9187,9 @@ t4_ioctl(struct cdev *dev, unsigned long cmd, caddr_t data, int fflag,
|
|||||||
case CHELSIO_T4_SET_TRACER:
|
case CHELSIO_T4_SET_TRACER:
|
||||||
rc = t4_set_tracer(sc, (struct t4_tracer *)data);
|
rc = t4_set_tracer(sc, (struct t4_tracer *)data);
|
||||||
break;
|
break;
|
||||||
|
case CHELSIO_T4_LOAD_CFG:
|
||||||
|
rc = load_cfg(sc, (struct t4_data *)data);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
rc = ENOTTY;
|
rc = ENOTTY;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,10 @@
|
|||||||
.It
|
.It
|
||||||
.Nm Ar nexus Cm i2c Ar port_id devaddr addr Op Ar len
|
.Nm Ar nexus Cm i2c Ar port_id devaddr addr Op Ar len
|
||||||
.It
|
.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
|
.Nm Ar nexus Cm loadfw Ar fw-image.bin
|
||||||
.It
|
.It
|
||||||
.Nm Ar nexus Cm memdump Ar addr len
|
.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
|
.It Cm filter Cm list
|
||||||
List all filters programmed into the hardware.
|
List all filters programmed into the hardware.
|
||||||
.It Cm i2c Ar port_id devaddr addr Op Ar len
|
.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
|
.It Cm loadfw Ar fw-image.bin
|
||||||
Install the firmware contained in
|
Install the firmware contained in
|
||||||
.Ar fw-image.bin
|
.Ar fw-image.bin
|
||||||
|
@ -95,6 +95,8 @@ usage(FILE *fp)
|
|||||||
"\tfilter list list all filters\n"
|
"\tfilter list list all filters\n"
|
||||||
"\tfilter mode [<match>] ... get/set global filter mode\n"
|
"\tfilter mode [<match>] ... get/set global filter mode\n"
|
||||||
"\ti2c <port> <devaddr> <addr> [<len>] read from i2c device\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"
|
"\tloadfw <fw-image.bin> install firmware\n"
|
||||||
"\tmemdump <addr> <len> dump a memory range\n"
|
"\tmemdump <addr> <len> dump a memory range\n"
|
||||||
"\tmodinfo <port> [raw] optics/cable information\n"
|
"\tmodinfo <port> [raw] optics/cable information\n"
|
||||||
@ -1834,6 +1836,49 @@ loadfw(int argc, const char *argv[])
|
|||||||
return (rc);
|
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
|
static int
|
||||||
read_mem(uint32_t addr, uint32_t len, void (*output)(uint32_t *, uint32_t))
|
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);
|
rc = sched_class(argc, argv);
|
||||||
else if (!strcmp(cmd, "sched-queue"))
|
else if (!strcmp(cmd, "sched-queue"))
|
||||||
rc = sched_queue(argc, argv);
|
rc = sched_queue(argc, argv);
|
||||||
|
else if (!strcmp(cmd, "loadcfg"))
|
||||||
|
rc = loadcfg(argc, argv);
|
||||||
else {
|
else {
|
||||||
rc = EINVAL;
|
rc = EINVAL;
|
||||||
warnx("invalid command \"%s\"", cmd);
|
warnx("invalid command \"%s\"", cmd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user