Changeset View
Changeset View
Standalone View
Standalone View
sbin/nvmecontrol/firmware.c
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | if ((chunk = aligned_alloc(PAGE_SIZE, NVME_MAX_XFER_SIZE)) == NULL) | ||||
errx(1, "unable to malloc %d bytes", NVME_MAX_XFER_SIZE); | errx(1, "unable to malloc %d bytes", NVME_MAX_XFER_SIZE); | ||||
while (resid > 0) { | while (resid > 0) { | ||||
size = (resid >= NVME_MAX_XFER_SIZE) ? | size = (resid >= NVME_MAX_XFER_SIZE) ? | ||||
NVME_MAX_XFER_SIZE : resid; | NVME_MAX_XFER_SIZE : resid; | ||||
memcpy(chunk, payload + off, size); | memcpy(chunk, payload + off, size); | ||||
memset(&pt, 0, sizeof(pt)); | memset(&pt, 0, sizeof(pt)); | ||||
pt.cmd.opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_FIRMWARE_IMAGE_DOWNLOAD); | pt.cmd.opc= NVME_OPC_FIRMWARE_IMAGE_DOWNLOAD; | ||||
smh: missing space before = | |||||
pt.cmd.cdw10 = htole32((size / sizeof(uint32_t)) - 1); | pt.cmd.cdw10 = htole32((size / sizeof(uint32_t)) - 1); | ||||
pt.cmd.cdw11 = htole32(off / sizeof(uint32_t)); | pt.cmd.cdw11 = htole32(off / sizeof(uint32_t)); | ||||
pt.buf = chunk; | pt.buf = chunk; | ||||
pt.len = size; | pt.len = size; | ||||
pt.is_read = 0; | pt.is_read = 0; | ||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | ||||
err(1, "firmware download request failed"); | err(1, "firmware download request failed"); | ||||
if (nvme_completion_is_error(&pt.cpl)) | if (nvme_completion_is_error(&pt.cpl)) | ||||
errx(1, "firmware download request returned error"); | errx(1, "firmware download request returned error"); | ||||
resid -= size; | resid -= size; | ||||
off += size; | off += size; | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
activate_firmware(int fd, int slot, int activate_action) | activate_firmware(int fd, int slot, int activate_action) | ||||
{ | { | ||||
struct nvme_pt_command pt; | struct nvme_pt_command pt; | ||||
uint16_t sct, sc; | uint16_t sct, sc; | ||||
memset(&pt, 0, sizeof(pt)); | memset(&pt, 0, sizeof(pt)); | ||||
pt.cmd.opc_fuse = NVME_CMD_SET_OPC(NVME_OPC_FIRMWARE_ACTIVATE); | pt.cmd.opc = NVME_OPC_FIRMWARE_ACTIVATE; | ||||
pt.cmd.cdw10 = htole32((activate_action << 3) | slot); | pt.cmd.cdw10 = htole32((activate_action << 3) | slot); | ||||
pt.is_read = 0; | pt.is_read = 0; | ||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | ||||
err(1, "firmware activate request failed"); | err(1, "firmware activate request failed"); | ||||
sct = NVME_STATUS_GET_SCT(pt.cpl.status); | sct = NVME_STATUS_GET_SCT(pt.cpl.status); | ||||
sc = NVME_STATUS_GET_SC(pt.cpl.status); | sc = NVME_STATUS_GET_SC(pt.cpl.status); | ||||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |
missing space before =