Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_virtio_net.c
Show First 20 Lines • Show All 555 Lines • ▼ Show 20 Lines | |||||
pci_vtnet_ping_ctlq(void *vsc, struct vqueue_info *vq) | pci_vtnet_ping_ctlq(void *vsc, struct vqueue_info *vq) | ||||
{ | { | ||||
DPRINTF(("vtnet: control qnotify!")); | DPRINTF(("vtnet: control qnotify!")); | ||||
} | } | ||||
#endif | #endif | ||||
static int | static int | ||||
pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) | pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) | ||||
{ | { | ||||
struct pci_vtnet_softc *sc; | struct pci_vtnet_softc *sc; | ||||
const char *value; | const char *value; | ||||
char tname[MAXCOMLEN + 1]; | char tname[MAXCOMLEN + 1]; | ||||
unsigned long mtu = ETHERMTU; | unsigned long mtu = ETHERMTU; | ||||
int err; | int err; | ||||
/* | /* | ||||
Show All 10 Lines | pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) | ||||
sc->vsc_queues[VTNET_RXQ].vq_notify = pci_vtnet_ping_rxq; | sc->vsc_queues[VTNET_RXQ].vq_notify = pci_vtnet_ping_rxq; | ||||
sc->vsc_queues[VTNET_TXQ].vq_qsize = VTNET_RINGSZ; | sc->vsc_queues[VTNET_TXQ].vq_qsize = VTNET_RINGSZ; | ||||
sc->vsc_queues[VTNET_TXQ].vq_notify = pci_vtnet_ping_txq; | sc->vsc_queues[VTNET_TXQ].vq_notify = pci_vtnet_ping_txq; | ||||
#ifdef notyet | #ifdef notyet | ||||
sc->vsc_queues[VTNET_CTLQ].vq_qsize = VTNET_RINGSZ; | sc->vsc_queues[VTNET_CTLQ].vq_qsize = VTNET_RINGSZ; | ||||
sc->vsc_queues[VTNET_CTLQ].vq_notify = pci_vtnet_ping_ctlq; | sc->vsc_queues[VTNET_CTLQ].vq_notify = pci_vtnet_ping_ctlq; | ||||
#endif | #endif | ||||
value = get_config_value_node(nvl, "mac"); | value = get_config_value_node(node, "mac"); | ||||
if (value != NULL) { | if (value != NULL) { | ||||
err = net_parsemac(value, sc->vsc_config.mac); | err = net_parsemac(value, sc->vsc_config.mac); | ||||
if (err) { | if (err) { | ||||
free(sc); | free(sc); | ||||
return (err); | return (err); | ||||
} | } | ||||
} else | } else | ||||
net_genmac(pi, sc->vsc_config.mac); | net_genmac(pi, sc->vsc_config.mac); | ||||
value = get_config_value_node(nvl, "mtu"); | value = get_config_value_node(node, "mtu"); | ||||
if (value != NULL) { | if (value != NULL) { | ||||
err = net_parsemtu(value, &mtu); | err = net_parsemtu(value, &mtu); | ||||
if (err) { | if (err) { | ||||
free(sc); | free(sc); | ||||
return (err); | return (err); | ||||
} | } | ||||
if (mtu < VTNET_MIN_MTU || mtu > VTNET_MAX_MTU) { | if (mtu < VTNET_MIN_MTU || mtu > VTNET_MAX_MTU) { | ||||
err = EINVAL; | err = EINVAL; | ||||
errno = EINVAL; | errno = EINVAL; | ||||
free(sc); | free(sc); | ||||
return (err); | return (err); | ||||
} | } | ||||
sc->vsc_consts.vc_hv_caps |= VIRTIO_NET_F_MTU; | sc->vsc_consts.vc_hv_caps |= VIRTIO_NET_F_MTU; | ||||
} | } | ||||
sc->vsc_config.mtu = mtu; | sc->vsc_config.mtu = mtu; | ||||
/* Permit interfaces without a configured backend. */ | /* Permit interfaces without a configured backend. */ | ||||
if (get_config_value_node(nvl, "backend") != NULL) { | if (get_config_value_node(node, "backend") != NULL) { | ||||
err = netbe_init(&sc->vsc_be, nvl, pci_vtnet_rx_callback, sc); | err = netbe_init(&sc->vsc_be, node, pci_vtnet_rx_callback, sc); | ||||
if (err) { | if (err) { | ||||
free(sc); | free(sc); | ||||
return (err); | return (err); | ||||
} | } | ||||
} | } | ||||
sc->vsc_consts.vc_hv_caps |= VIRTIO_NET_F_MRG_RXBUF | | sc->vsc_consts.vc_hv_caps |= VIRTIO_NET_F_MRG_RXBUF | | ||||
netbe_get_cap(sc->vsc_be); | netbe_get_cap(sc->vsc_be); | ||||
▲ Show 20 Lines • Show All 190 Lines • Show Last 20 Lines |