Re: svn commit: r304425 - stable/10/usr.sbin/bhyve

2016-08-20 Thread Sean C. Farley

On Thu, 18 Aug 2016, Alexander Motin wrote:


Author: mav
Date: Thu Aug 18 11:56:07 2016
New Revision: 304425
URL: https://svnweb.freebsd.org/changeset/base/304425

Log:
 MFC r302504, r302666, r302668, r302932, r302933:
 Add emulation for Intel e1000 (e82545) network adapter.

 The code was successfully tested with FreeBSD, Linux, Solaris and Windows
 guests.  This interface is predictably slower (about 2x) then virtio-net,
 but it is very helpful for guests not supporting virtio-net by default.

 Thanks to Jeremiah Lott and Peter Grehan for doing original heavy lifting.

Added:
 stable/10/usr.sbin/bhyve/pci_e82545.c
- copied, changed from r302504, head/usr.sbin/bhyve/pci_e82545.c
Modified:
 stable/10/usr.sbin/bhyve/Makefile
 stable/10/usr.sbin/bhyve/bhyve.8
Directory Properties:
 stable/10/   (props changed)

Modified: stable/10/usr.sbin/bhyve/Makefile
==
--- stable/10/usr.sbin/bhyve/Makefile   Thu Aug 18 11:51:14 2016
(r304424)
+++ stable/10/usr.sbin/bhyve/Makefile   Thu Aug 18 11:56:07 2016
(r304425)
@@ -23,6 +23,7 @@ SRCS= \
mevent.c\
mptbl.c \
pci_ahci.c  \
+   pci_e82545.c\
pci_emul.c  \
pci_hostbridge.c\
pci_irq.c   \
@@ -48,6 +49,10 @@ SRCS+=   vmm_instruction_emul.c
DPADD=  ${LIBVMMAPI} ${LIBMD} ${LIBUTIL} ${LIBPTHREAD}
LDADD=  -lvmmapi -lmd -lutil -lpthread

+CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/e1000
+CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/mii
+CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/usb/controller
+
WARNS?= 2

.include 


Alexander,

The MFC is a tiny bit incomplete.  I cannot build stable/10 world since 
BHYVE_SYSDIR is not defined in the usr.sbin/bhyve/Makefile as it is in 
HEAD.  The issue was only noticed because I do not have the source tree 
in /usr/src.  I presume the symlink that exists for /sys to usr/src/sys 
masks this for most people.



===> usr.sbin/bhyve (depend)
rm -f .depend
CC='cc  ' mkdep -f .depend -a-I/sys/dev/e1000 -I/sys/dev/mii 
-I/sys/dev/usb/controller -std=gnu99
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/atkbdc.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/acpi.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/bhyverun.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/block_if.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/bootrom.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/consport.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/dbgport.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/fwctl.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/inout.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/ioapic.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/mem.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/mevent.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/mptbl.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_ahci.c 
/usr/FreeBSD/branches/stable/10/src/usr.sb!
in/bhyve/pci_e82545.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_emul.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_hostbridge.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_irq.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_lpc.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_passthru.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_virtio_block.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_virtio_net.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_virtio_rnd.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_uart.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pm.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/post.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/rtc.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/smbiostbl.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/task_switch.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/uart_emul.c 
/usr/FreeBSD/branc!
hes/stable/10/src/usr.sbin/bhyve/virtio.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/xmsr.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/spinup_ap.c 
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/../../sys/amd64/vmm/vmm_instruction_emul.c
/usr/FreeBSD/branches/stable/10/src/usr.sbin/bhyve/pci_e82545.c:51:10: fatal 
error: 'e1000_regs.h' file not found
#include "e1000_regs.h"
 ^
1 error generated.
mkdep: compile failed
*** [.depend] Error code 1


This missing line completes the build, but I do not know if anything 
else needs merging.  The missing merge to the .PATH variable did not 
appear to affect the buildworld.


+ BHYVE_SYSDIR?=${SRCTOP}

Thank you.

Sean
--
s...@freebsd.org
___
svn-src-stable-10@freebsd.org mailing list

svn commit: r304425 - stable/10/usr.sbin/bhyve

2016-08-18 Thread Alexander Motin
Author: mav
Date: Thu Aug 18 11:56:07 2016
New Revision: 304425
URL: https://svnweb.freebsd.org/changeset/base/304425

Log:
  MFC r302504, r302666, r302668, r302932, r302933:
  Add emulation for Intel e1000 (e82545) network adapter.
  
  The code was successfully tested with FreeBSD, Linux, Solaris and Windows
  guests.  This interface is predictably slower (about 2x) then virtio-net,
  but it is very helpful for guests not supporting virtio-net by default.
  
  Thanks to Jeremiah Lott and Peter Grehan for doing original heavy lifting.

Added:
  stable/10/usr.sbin/bhyve/pci_e82545.c
 - copied, changed from r302504, head/usr.sbin/bhyve/pci_e82545.c
Modified:
  stable/10/usr.sbin/bhyve/Makefile
  stable/10/usr.sbin/bhyve/bhyve.8
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bhyve/Makefile
==
--- stable/10/usr.sbin/bhyve/Makefile   Thu Aug 18 11:51:14 2016
(r304424)
+++ stable/10/usr.sbin/bhyve/Makefile   Thu Aug 18 11:56:07 2016
(r304425)
@@ -23,6 +23,7 @@ SRCS= \
mevent.c\
mptbl.c \
pci_ahci.c  \
+   pci_e82545.c\
pci_emul.c  \
pci_hostbridge.c\
pci_irq.c   \
@@ -48,6 +49,10 @@ SRCS+=   vmm_instruction_emul.c
 DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBUTIL} ${LIBPTHREAD}
 LDADD= -lvmmapi -lmd -lutil -lpthread
 
+CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/e1000
+CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/mii
+CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/usb/controller
+
 WARNS?=2
 
 .include 

Modified: stable/10/usr.sbin/bhyve/bhyve.8
==
--- stable/10/usr.sbin/bhyve/bhyve.8Thu Aug 18 11:51:14 2016
(r304424)
+++ stable/10/usr.sbin/bhyve/bhyve.8Thu Aug 18 11:56:07 2016
(r304425)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 8, 2016
+.Dd July 9, 2016
 .Dt BHYVE 8
 .Os
 .Sh NAME
@@ -174,6 +174,8 @@ AHCI controller attached to arbitraty de
 AHCI controller attached to an ATAPI CD/DVD.
 .It Li ahci-hd
 AHCI controller attached to a SATA hard-drive.
+.It Li e1000
+Intel e82545 network interface.
 .It Li uart
 PCI 16550 serial device.
 .It Li lpc

Copied and modified: stable/10/usr.sbin/bhyve/pci_e82545.c (from r302504, 
head/usr.sbin/bhyve/pci_e82545.c)
==
--- head/usr.sbin/bhyve/pci_e82545.cSat Jul  9 20:41:59 2016
(r302504, copy source)
+++ stable/10/usr.sbin/bhyve/pci_e82545.c   Thu Aug 18 11:56:07 2016
(r304425)
@@ -109,12 +109,8 @@ __FBSDID("$FreeBSD$");
 
 #define E1000_ICR_SRPD 0x0001
 
-/*
- * XXX does this actually have a limit on the 82545 ?
- * There is a limit on the max number of bytes, but perhaps not
- * on descriptors ??
- */
-#define I82545_MAX_TXSEGS  20
+/* This is an arbitrary number.  There is no hard limit on the chip. */
+#define I82545_MAX_TXSEGS  64
 
 /* Legacy receive descriptor */
 struct e1000_rx_desc {
@@ -1050,15 +1046,18 @@ e82545_transmit_backend(struct e82545_so
 }
 
 static void
-e82545_transmit_done(struct e82545_softc *sc, union e1000_tx_udesc **txwb,
-int nwb)
+e82545_transmit_done(struct e82545_softc *sc, uint16_t head, uint16_t tail,
+uint16_t dsize, int *tdwb)
 {
-   int i;
+   union e1000_tx_udesc *dsc;
 
-   /* Write-back tx descriptor status */
-   for (i = 0; i < nwb; i++)
-   txwb[i]->td.upper.data |= E1000_TXD_STAT_DD;
-   /* XXX wmb() */
+   for ( ; head != tail; head = (head + 1) % dsize) {
+   dsc = >esc_txdesc[head];
+   if (dsc->td.lower.data & E1000_TXD_CMD_RS) {
+   dsc->td.upper.data |= E1000_TXD_STAT_DD;
+   *tdwb = 1;
+   }
+   }
 }
 
 static int
@@ -1068,22 +1067,21 @@ e82545_transmit(struct e82545_softc *sc,
uint8_t *hdr, *hdrp;
struct iovec iovb[I82545_MAX_TXSEGS + 2];
struct iovec tiov[I82545_MAX_TXSEGS + 2];
-   union e1000_tx_udesc *txwb[I82545_MAX_TXSEGS];
struct e1000_context_desc *cd;
struct ck_info ckinfo[2];
struct iovec *iov;
union  e1000_tx_udesc *dsc;
-   int desc, dtype, len, ntype, nwb, iovcnt, tlen, hdrlen, vlen, tcp, tso;
+   int desc, dtype, len, ntype, iovcnt, tlen, hdrlen, vlen, tcp, tso;
int mss, paylen, seg, tiovcnt, left, now, nleft, nnow, pv, pvoff;
uint32_t tcpsum, tcpseq;
-   uint16_t ipcs, tcpcs, ipid;
+   uint16_t ipcs, tcpcs, ipid, ohead;
 
ckinfo[0].ck_valid = ckinfo[1].ck_valid = 0;
iovcnt = 0;
tlen = 0;
-   nwb = 0;
ntype = 0;
tso = 0;
+   ohead = head;
 
/* iovb[0/1] may be used for writable copy of headers. */
iov = [2];
@@ -1104,11 +1102,8 @@ e82545_transmit(struct e82545_softc