Deleted Added
full compact
pci_virtio_net.c (330449) pci_virtio_net.c (336161)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2011 NetApp, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2011 NetApp, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: stable/11/usr.sbin/bhyve/pci_virtio_net.c 330449 2018-03-05 07:26:05Z eadler $
28 * $FreeBSD: stable/11/usr.sbin/bhyve/pci_virtio_net.c 336161 2018-07-10 04:26:32Z araujo $
29 */
30
31#include <sys/cdefs.h>
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: stable/11/usr.sbin/bhyve/pci_virtio_net.c 330449 2018-03-05 07:26:05Z eadler $");
32__FBSDID("$FreeBSD: stable/11/usr.sbin/bhyve/pci_virtio_net.c 336161 2018-07-10 04:26:32Z araujo $");
33
34#include <sys/param.h>
35#ifndef WITHOUT_CAPSICUM
36#include <sys/capsicum.h>
37#endif
38#include <sys/linker_set.h>
39#include <sys/select.h>
40#include <sys/uio.h>

--- 680 unchanged lines hidden (view full) ---

721
722 DPRINTF(("vtnet: control qnotify!\n\r"));
723}
724#endif
725
726static int
727pci_vtnet_parsemac(char *mac_str, uint8_t *mac_addr)
728{
33
34#include <sys/param.h>
35#ifndef WITHOUT_CAPSICUM
36#include <sys/capsicum.h>
37#endif
38#include <sys/linker_set.h>
39#include <sys/select.h>
40#include <sys/uio.h>

--- 680 unchanged lines hidden (view full) ---

721
722 DPRINTF(("vtnet: control qnotify!\n\r"));
723}
724#endif
725
726static int
727pci_vtnet_parsemac(char *mac_str, uint8_t *mac_addr)
728{
729 struct ether_addr *ea;
730 char *tmpstr;
731 char zero_addr[ETHER_ADDR_LEN] = { 0, 0, 0, 0, 0, 0 };
729 struct ether_addr *ea;
730 char *tmpstr;
731 char zero_addr[ETHER_ADDR_LEN] = { 0, 0, 0, 0, 0, 0 };
732
732
733 tmpstr = strsep(&mac_str,"=");
734
735 if ((mac_str != NULL) && (!strcmp(tmpstr,"mac"))) {
736 ea = ether_aton(mac_str);
733 tmpstr = strsep(&mac_str,"=");
737
734
738 if (ea == NULL || ETHER_IS_MULTICAST(ea->octet) ||
739 memcmp(ea->octet, zero_addr, ETHER_ADDR_LEN) == 0) {
735 if ((mac_str != NULL) && (!strcmp(tmpstr,"mac"))) {
736 ea = ether_aton(mac_str);
737
738 if (ea == NULL || ETHER_IS_MULTICAST(ea->octet) ||
739 memcmp(ea->octet, zero_addr, ETHER_ADDR_LEN) == 0) {
740 fprintf(stderr, "Invalid MAC %s\n", mac_str);
740 fprintf(stderr, "Invalid MAC %s\n", mac_str);
741 return (EINVAL);
742 } else
743 memcpy(mac_addr, ea->octet, ETHER_ADDR_LEN);
744 }
741 return (EINVAL);
742 } else
743 memcpy(mac_addr, ea->octet, ETHER_ADDR_LEN);
744 }
745
745
746 return (0);
746 return (0);
747}
748
749static void
750pci_vtnet_tap_setup(struct pci_vtnet_softc *sc, char *devname)
751{
752 char tbuf[80];
753#ifndef WITHOUT_CAPSICUM
754 cap_rights_t rights;

--- 172 unchanged lines hidden (view full) ---

927 * spawned.
928 */
929 sc->tx_in_progress = 0;
930 pthread_mutex_init(&sc->tx_mtx, NULL);
931 pthread_cond_init(&sc->tx_cond, NULL);
932 pthread_create(&sc->tx_tid, NULL, pci_vtnet_tx_thread, (void *)sc);
933 snprintf(tname, sizeof(tname), "vtnet-%d:%d tx", pi->pi_slot,
934 pi->pi_func);
747}
748
749static void
750pci_vtnet_tap_setup(struct pci_vtnet_softc *sc, char *devname)
751{
752 char tbuf[80];
753#ifndef WITHOUT_CAPSICUM
754 cap_rights_t rights;

--- 172 unchanged lines hidden (view full) ---

927 * spawned.
928 */
929 sc->tx_in_progress = 0;
930 pthread_mutex_init(&sc->tx_mtx, NULL);
931 pthread_cond_init(&sc->tx_cond, NULL);
932 pthread_create(&sc->tx_tid, NULL, pci_vtnet_tx_thread, (void *)sc);
933 snprintf(tname, sizeof(tname), "vtnet-%d:%d tx", pi->pi_slot,
934 pi->pi_func);
935 pthread_set_name_np(sc->tx_tid, tname);
935 pthread_set_name_np(sc->tx_tid, tname);
936
937 return (0);
938}
939
940static int
941pci_vtnet_cfgwrite(void *vsc, int offset, int size, uint32_t value)
942{
943 struct pci_vtnet_softc *sc = vsc;

--- 49 unchanged lines hidden ---
936
937 return (0);
938}
939
940static int
941pci_vtnet_cfgwrite(void *vsc, int offset, int size, uint32_t value)
942{
943 struct pci_vtnet_softc *sc = vsc;

--- 49 unchanged lines hidden ---