FWUG indicates the granularity and alignment requirement of the
firmware image being updated by the Firmware Image Download command
FWUG is reported in 4 KiB units
0h indicates that no information on granularity is provided
FFh indicates there is no restriction
so when this is 0 value, use 4 KiB split as a default
Do not override when xfer is given by user
-> Support for ignore fwug in (fwug>mdts) case
Reviewed-by: Keith Busch <keith.busch@gmail.com>
Reported-by: Minsik Jeon <hmi.jeon@samsung.com>
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
struct stat sb;
void *fw_buf;
bool huge;
+ struct nvme_id_ctrl ctrl;
struct config {
char *fw;
goto close_fw_fd;
}
- if (cfg.xfer == 0 || cfg.xfer % 4096)
+ if (cfg.xfer == 0) {
+ err = nvme_cli_identify_ctrl(dev, &ctrl);
+ if (err) {
+ fprintf(stderr, "identify-ctrl: %s\n", nvme_strerror(errno));
+ goto close_fw_fd;
+ }
+ if (ctrl.fwug == 0 || ctrl.fwug == 0xff)
+ cfg.xfer = 4096;
+ else
+ cfg.xfer = ctrl.fwug * 4096;
+ }
+ else if (cfg.xfer % 4096)
cfg.xfer = 4096;
if (cfg.xfer < HUGE_MIN)