Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/net_backend_netmap.c
| Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | |||||
| netmap_set_cap(struct net_backend *be, uint64_t features __unused, | netmap_set_cap(struct net_backend *be, uint64_t features __unused, | ||||
| unsigned vnet_hdr_len) | unsigned vnet_hdr_len) | ||||
| { | { | ||||
| return (netmap_set_vnet_hdr_len(be, vnet_hdr_len)); | return (netmap_set_vnet_hdr_len(be, vnet_hdr_len)); | ||||
| } | } | ||||
| static int | static int | ||||
| netmap_init(struct net_backend *be, const char *devname, | netmap_init(struct net_backend *be, const char *devname, nvlist_t *nvl, | ||||
| nvlist_t *nvl __unused, net_be_rxeof_t cb, void *param) | net_be_rxeof_t cb, void *param) | ||||
| { | { | ||||
| struct netmap_priv *priv = NET_BE_PRIV(be); | struct netmap_priv *priv = NET_BE_PRIV(be); | ||||
| size_t size; | |||||
| strlcpy(priv->ifname, devname, sizeof(priv->ifname)); | strlcpy(priv->ifname, devname, sizeof(priv->ifname)); | ||||
| priv->ifname[sizeof(priv->ifname) - 1] = '\0'; | priv->ifname[sizeof(priv->ifname) - 1] = '\0'; | ||||
| priv->nmd = nvlist_take_binary(nvl, "nm_desc", &size); | |||||
| priv->nmd = nm_open(priv->ifname, NULL, NETMAP_NO_TX_POLL, NULL); | |||||
| if (priv->nmd == NULL) { | |||||
| EPRINTLN("Unable to nm_open(): interface '%s', errno (%s)", | |||||
| devname, strerror(errno)); | |||||
| return (-1); | |||||
| } | |||||
| priv->memid = priv->nmd->req.nr_arg2; | priv->memid = priv->nmd->req.nr_arg2; | ||||
| priv->tx = NETMAP_TXRING(priv->nmd->nifp, 0); | priv->tx = NETMAP_TXRING(priv->nmd->nifp, 0); | ||||
| priv->rx = NETMAP_RXRING(priv->nmd->nifp, 0); | priv->rx = NETMAP_RXRING(priv->nmd->nifp, 0); | ||||
| priv->cb = cb; | priv->cb = cb; | ||||
| priv->cb_param = param; | priv->cb_param = param; | ||||
| be->fd = priv->nmd->fd; | be->fd = priv->nmd->fd; | ||||
| priv->mevp = mevent_add_disabled(be->fd, EVF_READ, cb, param); | priv->mevp = mevent_add_disabled(be->fd, EVF_READ, cb, param); | ||||
| if (priv->mevp == NULL) { | if (priv->mevp == NULL) { | ||||
| EPRINTLN("Could not register event"); | nvlist_add_string(nvl, "error", "Could not register event"); | ||||
| return (-1); | return (-1); | ||||
| } | } | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static void | static void | ||||
| netmap_cleanup(struct net_backend *be) | netmap_cleanup(struct net_backend *be) | ||||
| ▲ Show 20 Lines • Show All 226 Lines • Show Last 20 Lines | |||||