Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_e82545.c
Show First 20 Lines • Show All 527 Lines • ▼ Show 20 Lines | if (sc->nvm_bits == 0) { | ||||
break; | break; | ||||
} | } | ||||
case E82545_NVM_OPCODE_WRITE: | case E82545_NVM_OPCODE_WRITE: | ||||
sc->nvm_mode = E82545_NVM_MODE_DATAIN; | sc->nvm_mode = E82545_NVM_MODE_DATAIN; | ||||
sc->nvm_bits = E82545_NVM_DATA_BITS; | sc->nvm_bits = E82545_NVM_DATA_BITS; | ||||
sc->nvm_data = 0; | sc->nvm_data = 0; | ||||
break; | break; | ||||
default: | default: | ||||
DPRINTF("eeprom unknown op: 0x%x\r\r", | DPRINTF("eeprom unknown op: 0x%x\r\n", | ||||
sc->nvm_opaddr); | sc->nvm_opaddr); | ||||
/* back to opcode mode */ | /* back to opcode mode */ | ||||
sc->nvm_opaddr = 0; | sc->nvm_opaddr = 0; | ||||
sc->nvm_mode = E82545_NVM_MODE_OPADDR; | sc->nvm_mode = E82545_NVM_MODE_OPADDR; | ||||
sc->nvm_bits = E82545_NVM_OPADDR_BITS; | sc->nvm_bits = E82545_NVM_OPADDR_BITS; | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | e82545_ims_change(struct e82545_softc *sc, uint32_t bits) | ||||
new = bits & sc->esc_ICR & ~sc->esc_IMS; | new = bits & sc->esc_ICR & ~sc->esc_IMS; | ||||
sc->esc_IMS |= bits; | sc->esc_IMS |= bits; | ||||
if (new == 0) { | if (new == 0) { | ||||
DPRINTF("ims change: masked %x, ims %x\r\n", new, sc->esc_IMS); | DPRINTF("ims change: masked %x, ims %x\r\n", new, sc->esc_IMS); | ||||
} else if (sc->esc_mevpitr != NULL) { | } else if (sc->esc_mevpitr != NULL) { | ||||
DPRINTF("ims change: throttled %x, ims %x\r\n", new, sc->esc_IMS); | DPRINTF("ims change: throttled %x, ims %x\r\n", new, sc->esc_IMS); | ||||
} else if (!sc->esc_irq_asserted) { | } else if (!sc->esc_irq_asserted) { | ||||
DPRINTF("ims change: lintr assert %x\n\r", new); | DPRINTF("ims change: lintr assert %x\r\n", new); | ||||
sc->esc_irq_asserted = 1; | sc->esc_irq_asserted = 1; | ||||
pci_lintr_assert(sc->esc_pi); | pci_lintr_assert(sc->esc_pi); | ||||
if (sc->esc_ITR != 0) { | if (sc->esc_ITR != 0) { | ||||
sc->esc_mevpitr = mevent_add( | sc->esc_mevpitr = mevent_add( | ||||
(sc->esc_ITR + 3905) / 3906, /* 256ns -> 1ms */ | (sc->esc_ITR + 3905) / 3906, /* 256ns -> 1ms */ | ||||
EVF_TIMER, e82545_itr_callback, sc); | EVF_TIMER, e82545_itr_callback, sc); | ||||
} | } | ||||
} | } | ||||
Show All 16 Lines | if (sc->esc_irq_asserted && !(sc->esc_ICR & sc->esc_IMS)) { | ||||
sc->esc_irq_asserted = 0; | sc->esc_irq_asserted = 0; | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
e82545_intr_write(struct e82545_softc *sc, uint32_t offset, uint32_t value) | e82545_intr_write(struct e82545_softc *sc, uint32_t offset, uint32_t value) | ||||
{ | { | ||||
DPRINTF("intr_write: off %x, val %x\n\r", offset, value); | DPRINTF("intr_write: off %x, val %x\r\n", offset, value); | ||||
switch (offset) { | switch (offset) { | ||||
case E1000_ICR: | case E1000_ICR: | ||||
e82545_icr_deassert(sc, value); | e82545_icr_deassert(sc, value); | ||||
break; | break; | ||||
case E1000_ITR: | case E1000_ITR: | ||||
sc->esc_ITR = value; | sc->esc_ITR = value; | ||||
break; | break; | ||||
Show All 17 Lines | |||||
static uint32_t | static uint32_t | ||||
e82545_intr_read(struct e82545_softc *sc, uint32_t offset) | e82545_intr_read(struct e82545_softc *sc, uint32_t offset) | ||||
{ | { | ||||
uint32_t retval; | uint32_t retval; | ||||
retval = 0; | retval = 0; | ||||
DPRINTF("intr_read: off %x\n\r", offset); | DPRINTF("intr_read: off %x\r\n", offset); | ||||
switch (offset) { | switch (offset) { | ||||
case E1000_ICR: | case E1000_ICR: | ||||
retval = sc->esc_ICR; | retval = sc->esc_ICR; | ||||
sc->esc_ICR = 0; | sc->esc_ICR = 0; | ||||
e82545_icr_deassert(sc, ~0); | e82545_icr_deassert(sc, ~0); | ||||
break; | break; | ||||
case E1000_ITR: | case E1000_ITR: | ||||
Show All 17 Lines | |||||
static void | static void | ||||
e82545_devctl(struct e82545_softc *sc, uint32_t val) | e82545_devctl(struct e82545_softc *sc, uint32_t val) | ||||
{ | { | ||||
sc->esc_CTRL = val & ~E1000_CTRL_RST; | sc->esc_CTRL = val & ~E1000_CTRL_RST; | ||||
if (val & E1000_CTRL_RST) { | if (val & E1000_CTRL_RST) { | ||||
DPRINTF("e1k: s/w reset, ctl %x\n", val); | DPRINTF("e1k: s/w reset, ctl %x\r\n", val); | ||||
e82545_reset(sc, 1); | e82545_reset(sc, 1); | ||||
} | } | ||||
/* XXX check for phy reset ? */ | /* XXX check for phy reset ? */ | ||||
} | } | ||||
static void | static void | ||||
e82545_rx_update_rdba(struct e82545_softc *sc) | e82545_rx_update_rdba(struct e82545_softc *sc) | ||||
{ | { | ||||
Show All 12 Lines | |||||
{ | { | ||||
int on; | int on; | ||||
on = ((val & E1000_RCTL_EN) == E1000_RCTL_EN); | on = ((val & E1000_RCTL_EN) == E1000_RCTL_EN); | ||||
/* Save RCTL after stripping reserved bits 31:27,24,21,14,11:10,0 */ | /* Save RCTL after stripping reserved bits 31:27,24,21,14,11:10,0 */ | ||||
sc->esc_RCTL = val & ~0xF9204c01; | sc->esc_RCTL = val & ~0xF9204c01; | ||||
DPRINTF("rx_ctl - %s RCTL %x, val %x\n", | DPRINTF("rx_ctl - %s RCTL %x, val %x\r\n", | ||||
on ? "on" : "off", sc->esc_RCTL, val); | on ? "on" : "off", sc->esc_RCTL, val); | ||||
/* state change requested */ | /* state change requested */ | ||||
if (on != sc->esc_rx_enabled) { | if (on != sc->esc_rx_enabled) { | ||||
if (on) { | if (on) { | ||||
/* Catch disallowed/unimplemented settings */ | /* Catch disallowed/unimplemented settings */ | ||||
//assert(!(val & E1000_RCTL_LBM_TCVR)); | //assert(!(val & E1000_RCTL_LBM_TCVR)); | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | for (lim = size / 4; lim > 0 && left >= maxpktdesc; lim -= n) { | ||||
for (i = 0; i < maxpktdesc; i++) { | for (i = 0; i < maxpktdesc; i++) { | ||||
rxd = &sc->esc_rxdesc[(head + i) % size]; | rxd = &sc->esc_rxdesc[(head + i) % size]; | ||||
vec[i].iov_base = paddr_guest2host(sc->esc_ctx, | vec[i].iov_base = paddr_guest2host(sc->esc_ctx, | ||||
rxd->buffer_addr, bufsz); | rxd->buffer_addr, bufsz); | ||||
vec[i].iov_len = bufsz; | vec[i].iov_len = bufsz; | ||||
} | } | ||||
len = netbe_recv(sc->esc_be, vec, maxpktdesc); | len = netbe_recv(sc->esc_be, vec, maxpktdesc); | ||||
if (len <= 0) { | if (len <= 0) { | ||||
DPRINTF("netbe_recv() returned %d\n", len); | DPRINTF("netbe_recv() returned %d\r\n", len); | ||||
goto done; | goto done; | ||||
} | } | ||||
/* | /* | ||||
* Adjust the packet length based on whether the CRC needs | * Adjust the packet length based on whether the CRC needs | ||||
* to be stripped or if the packet is less than the minimum | * to be stripped or if the packet is less than the minimum | ||||
* eth packet size. | * eth packet size. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 991 Lines • Show Last 20 Lines |