Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/bhyve/pci_e82545.c
Show All 25 Lines | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#ifndef WITHOUT_CAPSICUM | |||||
#include <sys/capsicum.h> | |||||
#endif | |||||
#include <sys/limits.h> | #include <sys/limits.h> | ||||
#include <sys/ioctl.h> | #include <sys/ioctl.h> | ||||
#include <sys/uio.h> | #include <sys/uio.h> | ||||
#include <net/ethernet.h> | #include <net/ethernet.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/tcp.h> | #include <netinet/tcp.h> | ||||
#include <err.h> | |||||
#include <errno.h> | #include <errno.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <md5.h> | #include <md5.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <sysexits.h> | |||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <pthread.h> | #include <pthread.h> | ||||
#include <pthread_np.h> | #include <pthread_np.h> | ||||
#include "e1000_regs.h" | #include "e1000_regs.h" | ||||
#include "e1000_defines.h" | #include "e1000_defines.h" | ||||
#include "mii.h" | #include "mii.h" | ||||
▲ Show 20 Lines • Show All 2,142 Lines • ▼ Show 20 Lines | e82545_reset(struct e82545_softc *sc, int drvr) | ||||
sc->esc_TDHr = sc->esc_TDH = 0; | sc->esc_TDHr = sc->esc_TDH = 0; | ||||
sc->esc_TXDCTL = 0; | sc->esc_TXDCTL = 0; | ||||
} | } | ||||
static void | static void | ||||
e82545_open_tap(struct e82545_softc *sc, char *opts) | e82545_open_tap(struct e82545_softc *sc, char *opts) | ||||
{ | { | ||||
char tbuf[80]; | char tbuf[80]; | ||||
#ifndef WITHOUT_CAPSICUM | |||||
cap_rights_t rights; | |||||
#endif | |||||
if (opts == NULL) { | if (opts == NULL) { | ||||
sc->esc_tapfd = -1; | sc->esc_tapfd = -1; | ||||
return; | return; | ||||
} | } | ||||
strcpy(tbuf, "/dev/"); | strcpy(tbuf, "/dev/"); | ||||
strlcat(tbuf, opts, sizeof(tbuf)); | strlcat(tbuf, opts, sizeof(tbuf)); | ||||
Show All 9 Lines | #endif | ||||
* notifications with the event loop | * notifications with the event loop | ||||
*/ | */ | ||||
int opt = 1; | int opt = 1; | ||||
if (ioctl(sc->esc_tapfd, FIONBIO, &opt) < 0) { | if (ioctl(sc->esc_tapfd, FIONBIO, &opt) < 0) { | ||||
WPRINTF("tap device O_NONBLOCK failed: %d\n", errno); | WPRINTF("tap device O_NONBLOCK failed: %d\n", errno); | ||||
close(sc->esc_tapfd); | close(sc->esc_tapfd); | ||||
sc->esc_tapfd = -1; | sc->esc_tapfd = -1; | ||||
} | } | ||||
#ifndef WITHOUT_CAPSICUM | |||||
cap_rights_init(&rights, CAP_EVENT, CAP_READ, CAP_WRITE); | |||||
if (cap_rights_limit(sc->esc_tapfd, &rights) == -1 && errno != ENOSYS) | |||||
errx(EX_OSERR, "Unable to apply rights for sandbox"); | |||||
#endif | |||||
sc->esc_mevp = mevent_add(sc->esc_tapfd, | sc->esc_mevp = mevent_add(sc->esc_tapfd, | ||||
EVF_READ, | EVF_READ, | ||||
e82545_tap_callback, | e82545_tap_callback, | ||||
sc); | sc); | ||||
if (sc->esc_mevp == NULL) { | if (sc->esc_mevp == NULL) { | ||||
DPRINTF("Could not register mevent %d\n", EVF_READ); | DPRINTF("Could not register mevent %d\n", EVF_READ); | ||||
close(sc->esc_tapfd); | close(sc->esc_tapfd); | ||||
sc->esc_tapfd = -1; | sc->esc_tapfd = -1; | ||||
▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines |