Date: Sat, 25 Jul 2015 17:28:24 GMT From: iateaca@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r288767 - soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve Message-ID: <201507251728.t6PHSOsc022012@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: iateaca Date: Sat Jul 25 17:28:23 2015 New Revision: 288767 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=288767 Log: lock the reception flow with the .pe_barwrite and .pe_barwrite flows Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c ============================================================================== --- soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sat Jul 25 16:20:04 2015 (r288766) +++ soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sat Jul 25 17:28:23 2015 (r288767) @@ -7,6 +7,7 @@ #include <fcntl.h> #include <unistd.h> #include <string.h> +#include <pthread.h> #include <net/ethernet.h> @@ -63,6 +64,12 @@ struct pci_ne2000_softc { struct pci_devinst *asc_pi; + /* + * one single mutex used to lock the reception flow with + * the .pe_barwrite and .pe_barwrite flows + */ + pthread_mutex_t mtx; + /* NIC registers */ uint8_t nic_regs[NE2000_PAGE_COUNT][NE2000_PAGE_SIZE]; @@ -337,9 +344,15 @@ struct pci_ne2000_softc *sc = (struct pci_ne2000_softc *)param; assert(sc != NULL); + err = pthread_mutex_lock(&sc->mtx); + assert(err == 0); + err = ne2000_tap_rx(sc); assert(err == 0); + err = pthread_mutex_unlock(&sc->mtx); + assert(err == 0); + return; } @@ -507,6 +520,9 @@ return 1; } + err = pthread_mutex_init(&sc->mtx, NULL); + assert(err == 0); + err = ne2000_tap_init(sc, tap_name); assert(err == 0); @@ -548,6 +564,9 @@ assert(sc != NULL); assert(offset <= 0x0f); + err = pthread_mutex_lock(&sc->mtx); + assert(err == 0); + switch (baridx) { case NE2000_BAR_NIC: assert(size == 1); @@ -564,6 +583,9 @@ assert(err == 0); + err = pthread_mutex_unlock(&sc->mtx); + assert(err == 0); + return; } @@ -816,10 +838,14 @@ { struct pci_ne2000_softc *sc = pi->pi_arg; uint64_t value = 0; + int err; assert(sc != NULL); assert(offset <= 0x0f); + err = pthread_mutex_lock(&sc->mtx); + assert(err == 0); + switch (baridx) { case NE2000_BAR_NIC: assert(size == 1); @@ -833,6 +859,9 @@ assert(0); } + err = pthread_mutex_unlock(&sc->mtx); + assert(err == 0); + return value; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507251728.t6PHSOsc022012>
