- Add handling of MXGEFW_CMD_UNKNOWN in mxge_send_cmd().

- Convert mxge_send_cmd result handling to a switch rather
  than adding a new elseif for MXGEFW_CMD_UNKNOWN

Sponsored by: Myricom Inc.
This commit is contained in:
gallatin 2007-05-08 18:45:43 +00:00
parent ffa53534cf
commit d2dcd8a3d5

View File

@ -757,7 +757,7 @@ mxge_send_cmd(mxge_softc_t *sc, uint32_t cmd, mxge_cmd_t *data)
volatile mcp_cmd_response_t *response = sc->cmd; volatile mcp_cmd_response_t *response = sc->cmd;
volatile char *cmd_addr = sc->sram + MXGEFW_ETH_CMD; volatile char *cmd_addr = sc->sram + MXGEFW_ETH_CMD;
uint32_t dma_low, dma_high; uint32_t dma_low, dma_high;
int sleep_total = 0; int err, sleep_total = 0;
/* ensure buf is aligned to 8 bytes */ /* ensure buf is aligned to 8 bytes */
buf = (mcp_cmd_t *)((unsigned long)(buf_bytes + 7) & ~7UL); buf = (mcp_cmd_t *)((unsigned long)(buf_bytes + 7) & ~7UL);
@ -777,35 +777,42 @@ mxge_send_cmd(mxge_softc_t *sc, uint32_t cmd, mxge_cmd_t *data)
mxge_pio_copy((volatile void *)cmd_addr, buf, sizeof (*buf)); mxge_pio_copy((volatile void *)cmd_addr, buf, sizeof (*buf));
/* wait up to 20ms */ /* wait up to 20ms */
err = EAGAIN;
for (sleep_total = 0; sleep_total < 20; sleep_total++) { for (sleep_total = 0; sleep_total < 20; sleep_total++) {
bus_dmamap_sync(sc->cmd_dma.dmat, bus_dmamap_sync(sc->cmd_dma.dmat,
sc->cmd_dma.map, BUS_DMASYNC_POSTREAD); sc->cmd_dma.map, BUS_DMASYNC_POSTREAD);
mb(); mb();
if (response->result != 0xffffffff) { switch (be32toh(response->result)) {
if (response->result == 0) { case 0:
data->data0 = be32toh(response->data); data->data0 = be32toh(response->data);
mtx_unlock(&sc->cmd_mtx); err = 0;
return 0; break;
} else if (be32toh(response->result) == case 0xffffffff:
MXGEFW_CMD_ERROR_UNALIGNED) { DELAY(1000);
mtx_unlock(&sc->cmd_mtx); break;
return E2BIG; case MXGEFW_CMD_UNKNOWN:
} else { err = ENOSYS;
device_printf(sc->dev, break;
"mxge: command %d " case MXGEFW_CMD_ERROR_UNALIGNED:
"failed, result = %d\n", err = E2BIG;
cmd, be32toh(response->result)); break;
mtx_unlock(&sc->cmd_mtx); default:
return ENXIO; device_printf(sc->dev,
} "mxge: command %d "
"failed, result = %d\n",
cmd, be32toh(response->result));
err = ENXIO;
break;
} }
DELAY(1000); if (err != EAGAIN)
break;
} }
if (err == EAGAIN)
device_printf(sc->dev, "mxge: command %d timed out"
"result = %d\n",
cmd, be32toh(response->result));
mtx_unlock(&sc->cmd_mtx); mtx_unlock(&sc->cmd_mtx);
device_printf(sc->dev, "mxge: command %d timed out" return err;
"result = %d\n",
cmd, be32toh(response->result));
return EAGAIN;
} }
static int static int