Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/bhyve/pci_e82545.c
Show First 20 Lines • Show All 338 Lines • ▼ Show 20 Lines | struct e82545_softc { | ||||
uint64_t good_octets_tx; | uint64_t good_octets_tx; | ||||
uint64_t missed_octets; /* counts missed and oversized */ | uint64_t missed_octets; /* counts missed and oversized */ | ||||
uint8_t nvm_bits:6; /* number of bits remaining in/out */ | uint8_t nvm_bits:6; /* number of bits remaining in/out */ | ||||
uint8_t nvm_mode:2; | uint8_t nvm_mode:2; | ||||
#define E82545_NVM_MODE_OPADDR 0x0 | #define E82545_NVM_MODE_OPADDR 0x0 | ||||
#define E82545_NVM_MODE_DATAIN 0x1 | #define E82545_NVM_MODE_DATAIN 0x1 | ||||
#define E82545_NVM_MODE_DATAOUT 0x2 | #define E82545_NVM_MODE_DATAOUT 0x2 | ||||
/* EEPROM data */ | /* EEPROM data */ | ||||
uint16_t eeprom_data[E82545_NVM_EEPROM_SIZE]; | uint16_t eeprom_data[E82545_NVM_EEPROM_SIZE]; | ||||
}; | }; | ||||
static void e82545_reset(struct e82545_softc *sc, int dev); | static void e82545_reset(struct e82545_softc *sc, int dev); | ||||
static void e82545_rx_enable(struct e82545_softc *sc); | static void e82545_rx_enable(struct e82545_softc *sc); | ||||
static void e82545_rx_disable(struct e82545_softc *sc); | static void e82545_rx_disable(struct e82545_softc *sc); | ||||
static void e82545_tap_callback(int fd, enum ev_type type, void *param); | static void e82545_tap_callback(int fd, enum ev_type type, void *param); | ||||
static void e82545_tx_start(struct e82545_softc *sc); | static void e82545_tx_start(struct e82545_softc *sc); | ||||
static void e82545_tx_enable(struct e82545_softc *sc); | static void e82545_tx_enable(struct e82545_softc *sc); | ||||
▲ Show 20 Lines • Show All 1,110 Lines • ▼ Show 20 Lines | e82545_rx_disable(struct e82545_softc *sc) | ||||
sc->esc_rx_enabled = 0; | sc->esc_rx_enabled = 0; | ||||
while (sc->esc_rx_active) | while (sc->esc_rx_active) | ||||
pthread_cond_wait(&sc->esc_rx_cond, &sc->esc_mtx); | pthread_cond_wait(&sc->esc_rx_cond, &sc->esc_mtx); | ||||
} | } | ||||
static void | static void | ||||
e82545_write_ra(struct e82545_softc *sc, int reg, uint32_t wval) | e82545_write_ra(struct e82545_softc *sc, int reg, uint32_t wval) | ||||
{ | { | ||||
struct eth_uni *eu; | struct eth_uni *eu; | ||||
int idx; | int idx; | ||||
idx = reg >> 1; | idx = reg >> 1; | ||||
assert(idx < 15); | assert(idx < 15); | ||||
eu = &sc->esc_uni[idx]; | eu = &sc->esc_uni[idx]; | ||||
if (reg & 0x1) { | if (reg & 0x1) { | ||||
Show All 9 Lines | if (reg & 0x1) { | ||||
eu->eu_eth.octet[1] = wval >> 8; | eu->eu_eth.octet[1] = wval >> 8; | ||||
eu->eu_eth.octet[0] = wval; | eu->eu_eth.octet[0] = wval; | ||||
} | } | ||||
} | } | ||||
static uint32_t | static uint32_t | ||||
e82545_read_ra(struct e82545_softc *sc, int reg) | e82545_read_ra(struct e82545_softc *sc, int reg) | ||||
{ | { | ||||
struct eth_uni *eu; | struct eth_uni *eu; | ||||
uint32_t retval; | uint32_t retval; | ||||
int idx; | int idx; | ||||
idx = reg >> 1; | idx = reg >> 1; | ||||
assert(idx < 15); | assert(idx < 15); | ||||
eu = &sc->esc_uni[idx]; | eu = &sc->esc_uni[idx]; | ||||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | e82545_write_register(struct e82545_softc *sc, uint32_t offset, uint32_t value) | ||||
} | } | ||||
} | } | ||||
static uint32_t | static uint32_t | ||||
e82545_read_register(struct e82545_softc *sc, uint32_t offset) | e82545_read_register(struct e82545_softc *sc, uint32_t offset) | ||||
{ | { | ||||
uint32_t retval; | uint32_t retval; | ||||
int ridx; | int ridx; | ||||
if (offset & 0x3) { | if (offset & 0x3) { | ||||
DPRINTF("Unaligned register read offset:0x%x\r\n", offset); | DPRINTF("Unaligned register read offset:0x%x\r\n", offset); | ||||
return 0; | return 0; | ||||
} | } | ||||
DPRINTF("Register read: 0x%x\r\n", offset); | DPRINTF("Register read: 0x%x\r\n", offset); | ||||
switch (offset) { | switch (offset) { | ||||
case E1000_CTRL: | case E1000_CTRL: | ||||
retval = sc->esc_CTRL; | retval = sc->esc_CTRL; | ||||
break; | break; | ||||
case E1000_STATUS: | case E1000_STATUS: | ||||
retval = E1000_STATUS_FD | E1000_STATUS_LU | | retval = E1000_STATUS_FD | E1000_STATUS_LU | | ||||
▲ Show 20 Lines • Show All 630 Lines • Show Last 20 Lines |