[Differential] D9904: fix UEFI boot on physical machines

2017-03-06 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS314770: loader.efi: fix recent UEFI-boot regression on 
physical machines (authored by dexuan).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D9904?vs=26023&id=26027#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D9904?vs=26023&id=26027

REVISION DETAIL
  https://reviews.freebsd.org/D9904

AFFECTED FILES
  head/sys/boot/efi/loader/copy.c

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: decui_microsoft.com, imp, jhb, will, kib, delphij, emaste, marcel, 
honzhan_microsoft.com, howard0su_gmail.com, tsoome, gonzo, manu, andrew, 
sbruno, ambrisko, allanjude, bapt, cem, smh, ian, sepherosa_gmail.com
Cc: freebsd-virtualization-list
diff --git a/head/sys/boot/efi/loader/copy.c b/head/sys/boot/efi/loader/copy.c
--- a/head/sys/boot/efi/loader/copy.c
+++ b/head/sys/boot/efi/loader/copy.c
@@ -53,7 +53,7 @@
 	UINT32 dver;
 	EFI_STATUS status;
 	int i, ndesc;
-	unsigned long available_pages;
+	unsigned long available_pages = 0;
 
 	sz = 0;
 	status = BS->GetMemoryMap(&sz, 0, &key, &dsz, &dver);
@@ -70,7 +70,6 @@
 	}
 
 	ndesc = sz / dsz;
-
 	for (i = 0, p = map; i < ndesc;
 	 i++, p = NextMemoryDescriptor(p, dsz)) {
 		start = p->PhysicalStart;
@@ -81,20 +80,38 @@
 			continue;
 
 		if (p->Type != EfiConventionalMemory)
-			continue;
+			printf("Warning: wrong EFI memory type: %d\n",
+			p->Type);
 
 		available_pages = p->NumberOfPages -
 			((KERNEL_PHYSICAL_BASE - start) >> EFI_PAGE_SHIFT);
+		break;
+	}
+
+	if (available_pages == 0) {
+		printf("Can't find valid memory map for staging area!\n");
+		goto out;
+	}
 
-		if (*nr_pages > available_pages) {
-			printf("staging area size is reduced: %ld -> %ld!\n",
-			*nr_pages, available_pages);
-			*nr_pages = available_pages;
-		}
+	for ( ; i < ndesc;
+	 i++, p = NextMemoryDescriptor(p, dsz)) {
+		if (p->Type != EfiConventionalMemory &&
+		p->Type != EfiLoaderData)
+			break;
 
-		break;
+		if (p->PhysicalStart != end)
+			break;
+
+		end = p->PhysicalStart + p->NumberOfPages * EFI_PAGE_SIZE;
+
+		available_pages += p->NumberOfPages;
 	}
 
+	if (*nr_pages > available_pages) {
+		printf("Staging area's size is reduced: %ld -> %ld!\n",
+		*nr_pages, available_pages);
+		*nr_pages = available_pages;
+	}
 out:
 	free(map);
 }

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"

[Differential] D9686: fix UEFI VM's bootup on Hyper-V (i.e. Hyper-V Generation-2 VM)

2017-03-01 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS314547: loader.efi: reduce the size of the staging area if 
necessary (authored by dexuan).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D9686?vs=25505&id=25869#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D9686?vs=25505&id=25869

REVISION DETAIL
  https://reviews.freebsd.org/D9686

AFFECTED FILES
  head/sys/boot/efi/loader/copy.c

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: decui_microsoft.com, imp, jhb, will, kib, delphij, emaste, 
honzhan_microsoft.com, howard0su_gmail.com, marcel, tsoome, gonzo, manu, 
andrew, sbruno, ambrisko, allanjude, bapt, cem, smh, ian, sepherosa_gmail.com
Cc: freebsd-virtualization-list
diff --git a/head/sys/boot/efi/loader/copy.c b/head/sys/boot/efi/loader/copy.c
--- a/head/sys/boot/efi/loader/copy.c
+++ b/head/sys/boot/efi/loader/copy.c
@@ -39,12 +39,71 @@
 
 #include "loader_efi.h"
 
+#if defined(__i386__) || defined(__amd64__)
+
+#define KERNEL_PHYSICAL_BASE (2*1024*1024)
+
+static void
+efi_verify_staging_size(unsigned long *nr_pages)
+{
+	UINTN sz;
+	EFI_MEMORY_DESCRIPTOR *map, *p;
+	EFI_PHYSICAL_ADDRESS start, end;
+	UINTN key, dsz;
+	UINT32 dver;
+	EFI_STATUS status;
+	int i, ndesc;
+	unsigned long available_pages;
+
+	sz = 0;
+	status = BS->GetMemoryMap(&sz, 0, &key, &dsz, &dver);
+	if (status != EFI_BUFFER_TOO_SMALL) {
+		printf("Can't determine memory map size\n");
+		return;
+	}
+
+	map = malloc(sz);
+	status = BS->GetMemoryMap(&sz, map, &key, &dsz, &dver);
+	if (EFI_ERROR(status)) {
+		printf("Can't read memory map\n");
+		goto out;
+	}
+
+	ndesc = sz / dsz;
+
+	for (i = 0, p = map; i < ndesc;
+	 i++, p = NextMemoryDescriptor(p, dsz)) {
+		start = p->PhysicalStart;
+		end = start + p->NumberOfPages * EFI_PAGE_SIZE;
+
+		if (KERNEL_PHYSICAL_BASE < start ||
+		KERNEL_PHYSICAL_BASE >= end)
+			continue;
+
+		if (p->Type != EfiConventionalMemory)
+			continue;
+
+		available_pages = p->NumberOfPages -
+			((KERNEL_PHYSICAL_BASE - start) >> EFI_PAGE_SHIFT);
+
+		if (*nr_pages > available_pages) {
+			printf("staging area size is reduced: %ld -> %ld!\n",
+			*nr_pages, available_pages);
+			*nr_pages = available_pages;
+		}
+
+		break;
+	}
+
+out:
+	free(map);
+}
+#endif
+
 #ifndef EFI_STAGING_SIZE
 #define	EFI_STAGING_SIZE	64
 #endif
 
-#define	STAGE_PAGES	EFI_SIZE_TO_PAGES((EFI_STAGING_SIZE) * 1024 * 1024)
-
 EFI_PHYSICAL_ADDRESS	staging, staging_end;
 int			stage_offset_set = 0;
 ssize_t			stage_offset;
@@ -54,14 +113,32 @@
 {
 	EFI_STATUS	status;
 
+	unsigned long nr_pages;
+
+	nr_pages = EFI_SIZE_TO_PAGES((EFI_STAGING_SIZE) * 1024 * 1024);
+
+#if defined(__i386__) || defined(__amd64__)
+	/* We'll decrease nr_pages, if it's too big. */
+	efi_verify_staging_size(&nr_pages);
+
+	/*
+	 * The staging area must reside in the the first 1GB physical
+	 * memory: see elf64_exec() in
+	 * boot/efi/loader/arch/amd64/elf64_freebsd.c.
+	 */
+	staging = 1024*1024*1024;
+	status = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData,
+	nr_pages, &staging);
+#else
 	status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData,
-	STAGE_PAGES, &staging);
+	nr_pages, &staging);
+#endif
 	if (EFI_ERROR(status)) {
 		printf("failed to allocate staging area: %lu\n",
 		EFI_ERROR_CODE(status));
 		return (status);
 	}
-	staging_end = staging + STAGE_PAGES * EFI_PAGE_SIZE;
+	staging_end = staging + nr_pages * EFI_PAGE_SIZE;
 
 #if defined(__aarch64__) || defined(__arm__)
 	/*

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"

[Differential] [Closed] D5318: hyperv/hn: Free the txdesc buf_ring when the TX ring is destroyed

2016-02-18 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295794: hyperv/hn: Free the txdesc buf_ring when the TX ring 
is destroyed (authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5318?vs=13409&id=13482#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5318?vs=13409&id=13482

REVISION DETAIL
  https://reviews.freebsd.org/D5318

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

CHANGE DETAILS
  diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c 
b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  --- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  +++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  @@ -2276,6 +2276,11 @@
bus_dma_tag_destroy(txr->hn_tx_data_dtag);
if (txr->hn_tx_rndis_dtag != NULL)
bus_dma_tag_destroy(txr->hn_tx_rndis_dtag);
  +
  +#ifdef HN_USE_TXDESC_BUFRING
  + buf_ring_free(txr->hn_txdesc_br, M_NETVSC);
  +#endif
  +
free(txr->hn_txdesc, M_NETVSC);
txr->hn_txdesc = NULL;

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -2276,6 +2276,11 @@
 		bus_dma_tag_destroy(txr->hn_tx_data_dtag);
 	if (txr->hn_tx_rndis_dtag != NULL)
 		bus_dma_tag_destroy(txr->hn_tx_rndis_dtag);
+
+#ifdef HN_USE_TXDESC_BUFRING
+	buf_ring_free(txr->hn_txdesc_br, M_NETVSC);
+#endif
+
 	free(txr->hn_txdesc, M_NETVSC);
 	txr->hn_txdesc = NULL;
 

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"

[Differential] [Closed] D5317: hyperv/hn: Enable IP header checksum offloading for WIN8 (WinServ2012)

2016-02-18 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295793: hyperv/hn: Enable IP header checksum offloading for 
WIN8 (WinServ2012) (authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5317?vs=13408&id=13481#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5317?vs=13408&id=13481

REVISION DETAIL
  https://reviews.freebsd.org/D5317

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

CHANGE DETAILS
  diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c 
b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  --- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  +++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  @@ -176,7 +176,7 @@
* later.  UDP checksum offloading doesn't work on earlier
* Windows releases.
*/
  -#define HN_CSUM_ASSIST_WIN8  (CSUM_TCP)
  +#define HN_CSUM_ASSIST_WIN8  (CSUM_IP | CSUM_TCP)
   #define HN_CSUM_ASSIST   (CSUM_IP | CSUM_UDP | CSUM_TCP)
   
   #define HN_LRO_LENLIM_DEF(25 * ETHERMTU)

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -176,7 +176,7 @@
  * later.  UDP checksum offloading doesn't work on earlier
  * Windows releases.
  */
-#define HN_CSUM_ASSIST_WIN8	(CSUM_TCP)
+#define HN_CSUM_ASSIST_WIN8	(CSUM_IP | CSUM_TCP)
 #define HN_CSUM_ASSIST		(CSUM_IP | CSUM_UDP | CSUM_TCP)
 
 #define HN_LRO_LENLIM_DEF		(25 * ETHERMTU)

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"

[Differential] [Closed] D5316: hyperv/hn: Add option to bind TX taskqueues to the specified CPU

2016-02-18 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295792: hyperv/hn: Add option to bind TX taskqueues to the 
specified CPU (authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5316?vs=13407&id=13480#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5316?vs=13407&id=13480

REVISION DETAIL
  https://reviews.freebsd.org/D5316

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

CHANGE DETAILS
  diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c 
b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  --- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  +++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  @@ -269,6 +269,10 @@
   SYSCTL_INT(_hw_hn, OID_AUTO, use_txdesc_bufring, CTLFLAG_RD,
   &hn_use_txdesc_bufring, 0, "Use buf_ring for TX descriptors");
   
  +static int hn_bind_tx_taskq = -1;
  +SYSCTL_INT(_hw_hn, OID_AUTO, bind_tx_taskq, CTLFLAG_RDTUN,
  +&hn_bind_tx_taskq, 0, "Bind TX taskqueue to the specified cpu");
  +
   /*
* Forward declarations
*/
  @@ -383,8 +387,20 @@
if (hn_tx_taskq == NULL) {
sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
taskqueue_thread_enqueue, &sc->hn_tx_taskq);
  - taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx",
  - device_get_nameunit(dev));
  + if (hn_bind_tx_taskq >= 0) {
  + int cpu = hn_bind_tx_taskq;
  + cpuset_t cpu_set;
  +
  + if (cpu > mp_ncpus - 1)
  + cpu = mp_ncpus - 1;
  + CPU_SETOF(cpu, &cpu_set);
  + taskqueue_start_threads_cpuset(&sc->hn_tx_taskq, 1,
  + PI_NET, &cpu_set, "%s tx",
  + device_get_nameunit(dev));
  + } else {
  + taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET,
  + "%s tx", device_get_nameunit(dev));
  + }
} else {
sc->hn_tx_taskq = hn_tx_taskq;
}
  @@ -2409,7 +2425,18 @@
   
hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
taskqueue_thread_enqueue, &hn_tx_taskq);
  - taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx");
  + if (hn_bind_tx_taskq >= 0) {
  + int cpu = hn_bind_tx_taskq;
  + cpuset_t cpu_set;
  +
  + if (cpu > mp_ncpus - 1)
  + cpu = mp_ncpus - 1;
  + CPU_SETOF(cpu, &cpu_set);
  + taskqueue_start_threads_cpuset(&hn_tx_taskq, 1, PI_NET,
  + &cpu_set, "hn tx");
  + } else {
  + taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx");
  + }
   }
   SYSINIT(hn_txtq_create, SI_SUB_DRIVERS, SI_ORDER_FIRST,
   hn_tx_taskq_create, NULL);

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -269,6 +269,10 @@
 SYSCTL_INT(_hw_hn, OID_AUTO, use_txdesc_bufring, CTLFLAG_RD,
 &hn_use_txdesc_bufring, 0, "Use buf_ring for TX descriptors");
 
+static int hn_bind_tx_taskq = -1;
+SYSCTL_INT(_hw_hn, OID_AUTO, bind_tx_taskq, CTLFLAG_RDTUN,
+&hn_bind_tx_taskq, 0, "Bind TX taskqueue to the specified cpu");
+
 /*
  * Forward declarations
  */
@@ -383,8 +387,20 @@
 	if (hn_tx_taskq == NULL) {
 		sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
 		taskqueue_thread_enqueue, &sc->hn_tx_taskq);
-		taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx",
-		device_get_nameunit(dev));
+		if (hn_bind_tx_taskq >= 0) {
+			int cpu = hn_bind_tx_taskq;
+			cpuset_t cpu_set;
+
+			if (cpu > mp_ncpus - 1)
+cpu = mp_ncpus - 1;
+			CPU_SETOF(cpu, &cpu_set);
+			taskqueue_start_threads_cpuset(&sc->hn_tx_taskq, 1,
+			PI_NET, &cpu_set, "%s tx",
+			device_get_nameunit(dev));
+		} else {
+			taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET,
+			"%s tx", device_get_nameunit(dev));
+		}
 	} else {
 		sc->hn_tx_taskq = hn_tx_taskq;
 	}
@@ -2409,7 +2425,18 @@
 
 	hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
 	taskqueue_thread_enqueue, &hn_tx_taskq);
-	taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx");
+	if (hn_bind_tx_taskq >= 0) {
+		int cpu = hn_bind_tx_taskq;
+		cpuset_t cpu_set;
+
+		if (cpu > mp_ncpus - 1)
+			cpu = mp_ncpus - 1;
+		CPU_SETOF(cpu, &cpu_set);
+		taskqueue_start_threads_cpuset(&hn_tx_taskq, 1, PI_NET,
+		&cpu_set, "hn tx");
+	} else {
+		taskqueue_start_thread

[Differential] [Closed] D5283: hyperv/hn: Split TX ring data structure out of softc

2016-02-18 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295747: hyperv/hn: Split TX ring data structure out of softc 
(authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5283?vs=13312&id=13405#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5283?vs=13312&id=13405

REVISION DETAIL
  https://reviews.freebsd.org/D5283

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -153,7 +153,7 @@
 struct hn_txdesc {
 	SLIST_ENTRY(hn_txdesc) link;
 	struct mbuf	*m;
-	struct hn_softc	*sc;
+	struct hn_tx_ring *txr;
 	int		refs;
 	uint32_t	flags;		/* HN_TXD_FLAG_ */
 	netvsc_packet	netvsc_pkt;	/* XXX to be removed */
@@ -193,7 +193,6 @@
 #define NV_LOCK_INIT(_sc, _name) \
 	mtx_init(&(_sc)->hn_lock, _name, MTX_NETWORK_LOCK, MTX_DEF)
 #define NV_LOCK(_sc)		mtx_lock(&(_sc)->hn_lock)
-#define NV_TRYLOCK(_sc)		mtx_trylock(&(_sc)->hn_lock)
 #define NV_LOCK_ASSERT(_sc)	mtx_assert(&(_sc)->hn_lock, MA_OWNED)
 #define NV_UNLOCK(_sc)		mtx_unlock(&(_sc)->hn_lock)
 #define NV_LOCK_DESTROY(_sc)	mtx_destroy(&(_sc)->hn_lock)
@@ -266,25 +265,31 @@
 static void hn_ifinit_locked(hn_softc_t *sc);
 static void hn_ifinit(void *xsc);
 static int  hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
-static int hn_start_locked(struct ifnet *ifp, int len);
+static int hn_start_locked(struct hn_tx_ring *txr, int len);
 static void hn_start(struct ifnet *ifp);
-static void hn_start_txeof(struct ifnet *ifp);
+static void hn_start_txeof(struct hn_tx_ring *);
 static int hn_ifmedia_upd(struct ifnet *ifp);
 static void hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr);
 static int hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_tx_chimney_size_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS);
+static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS);
+static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_check_iplen(const struct mbuf *, int);
-static int hn_create_tx_ring(struct hn_softc *sc);
-static void hn_destroy_tx_ring(struct hn_softc *sc);
+static int hn_create_tx_ring(struct hn_softc *, int);
+static void hn_destroy_tx_ring(struct hn_tx_ring *);
+static int hn_create_tx_data(struct hn_softc *);
+static void hn_destroy_tx_data(struct hn_softc *);
 static void hn_start_taskfunc(void *xsc, int pending);
 static void hn_txeof_taskfunc(void *xsc, int pending);
-static int hn_encap(struct hn_softc *, struct hn_txdesc *, struct mbuf **);
+static void hn_stop_tx_tasks(struct hn_softc *);
+static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **);
 static void hn_create_rx_data(struct hn_softc *sc);
 static void hn_destroy_rx_data(struct hn_softc *sc);
+static void hn_set_tx_chimney_size(struct hn_softc *, int);
 
 static int
 hn_ifmedia_upd(struct ifnet *ifp __unused)
@@ -350,8 +355,6 @@
 	hn_softc_t *sc;
 	int unit = device_get_unit(dev);
 	struct ifnet *ifp = NULL;
-	struct sysctl_oid_list *child;
-	struct sysctl_ctx_list *ctx;
 	int error;
 #if __FreeBSD_version >= 1100045
 	int tso_maxlen;
@@ -365,7 +368,6 @@
 	bzero(sc, sizeof(hn_softc_t));
 	sc->hn_unit = unit;
 	sc->hn_dev = dev;
-	sc->hn_direct_tx_size = hn_direct_tx_size;
 
 	if (hn_tx_taskq == NULL) {
 		sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
@@ -375,20 +377,17 @@
 	} else {
 		sc->hn_tx_taskq = hn_tx_taskq;
 	}
-	TASK_INIT(&sc->hn_start_task, 0, hn_start_taskfunc, sc);
-	TASK_INIT(&sc->hn_txeof_task, 0, hn_txeof_taskfunc, sc);
-
-	error = hn_create_tx_ring(sc);
-	if (error)
-		goto failed;
-
 	NV_LOCK_INIT(sc, "NetVSCLock");
 
 	sc->hn_dev_obj = device_ctx;
 
 	ifp = sc->hn_ifp = if_alloc(IFT_ETHER);
 	ifp->if_softc = sc;
 
+	error = hn_create_tx_data(sc);
+	if (error)
+		goto failed;
+
 	hn_create_rx_data(sc);
 
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
@@ -421,12 +420,7 @@
 	ifp->if_capenable |=
 	IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO |
 	IFCAP_LRO;
-
-	if (hv_vmbus_protocal_version >= HV_VMBUS_VERSION_WIN8_1)
-		sc->hn_csum_assist = HN_CSUM_ASSIST;
-	else
-		sc->hn_csum_assist = HN_CSUM_ASSIST_WIN8;
-	ifp->if_hwassist = sc->hn_csum_assist | CSUM_TSO;
+	ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CS

[Differential] [Closed] D5290: hyperv/hn: Use buf_ring for txdesc list

2016-02-17 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295748: hyperv/hn: Use buf_ring for txdesc list (authored by 
sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5290?vs=13340&id=13406#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5290?vs=13340&id=13406

REVISION DETAIL
  https://reviews.freebsd.org/D5290

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -70,6 +70,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -151,7 +152,9 @@
 #define HN_DIRECT_TX_SIZE_DEF		128
 
 struct hn_txdesc {
+#ifndef HN_USE_TXDESC_BUFRING
 	SLIST_ENTRY(hn_txdesc) link;
+#endif
 	struct mbuf	*m;
 	struct hn_tx_ring *txr;
 	int		refs;
@@ -258,6 +261,14 @@
 
 static struct taskqueue	*hn_tx_taskq;
 
+#ifndef HN_USE_TXDESC_BUFRING
+static int hn_use_txdesc_bufring = 0;
+#else
+static int hn_use_txdesc_bufring = 1;
+#endif
+SYSCTL_INT(_hw_hn, OID_AUTO, use_txdesc_bufring, CTLFLAG_RD,
+&hn_use_txdesc_bufring, 0, "Use buf_ring for TX descriptors");
+
 /*
  * Forward declarations
  */
@@ -570,13 +581,18 @@
 
 	txd->flags |= HN_TXD_FLAG_ONLIST;
 
+#ifndef HN_USE_TXDESC_BUFRING
 	mtx_lock_spin(&txr->hn_txlist_spin);
 	KASSERT(txr->hn_txdesc_avail >= 0 &&
 	txr->hn_txdesc_avail < txr->hn_txdesc_cnt,
 	("txdesc_put: invalid txd avail %d", txr->hn_txdesc_avail));
 	txr->hn_txdesc_avail++;
 	SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link);
 	mtx_unlock_spin(&txr->hn_txlist_spin);
+#else
+	atomic_add_int(&txr->hn_txdesc_avail, 1);
+	buf_ring_enqueue(txr->hn_txdesc_br, txd);
+#endif
 
 	return 1;
 }
@@ -586,6 +602,7 @@
 {
 	struct hn_txdesc *txd;
 
+#ifndef HN_USE_TXDESC_BUFRING
 	mtx_lock_spin(&txr->hn_txlist_spin);
 	txd = SLIST_FIRST(&txr->hn_txlist);
 	if (txd != NULL) {
@@ -595,8 +612,14 @@
 		SLIST_REMOVE_HEAD(&txr->hn_txlist, link);
 	}
 	mtx_unlock_spin(&txr->hn_txlist_spin);
+#else
+	txd = buf_ring_dequeue_sc(txr->hn_txdesc_br);
+#endif
 
 	if (txd != NULL) {
+#ifdef HN_USE_TXDESC_BUFRING
+		atomic_subtract_int(&txr->hn_txdesc_avail, 1);
+#endif
 		KASSERT(txd->m == NULL && txd->refs == 0 &&
 		(txd->flags & HN_TXD_FLAG_ONLIST), ("invalid txd"));
 		txd->flags &= ~HN_TXD_FLAG_ONLIST;
@@ -2048,13 +2071,20 @@
 
 	txr->hn_sc = sc;
 
+#ifndef HN_USE_TXDESC_BUFRING
 	mtx_init(&txr->hn_txlist_spin, "hn txlist", NULL, MTX_SPIN);
+#endif
 	mtx_init(&txr->hn_tx_lock, "hn tx", NULL, MTX_DEF);
 
 	txr->hn_txdesc_cnt = HN_TX_DESC_CNT;
 	txr->hn_txdesc = malloc(sizeof(struct hn_txdesc) * txr->hn_txdesc_cnt,
 	M_NETVSC, M_WAITOK | M_ZERO);
+#ifndef HN_USE_TXDESC_BUFRING
 	SLIST_INIT(&txr->hn_txlist);
+#else
+	txr->hn_txdesc_br = buf_ring_alloc(txr->hn_txdesc_cnt, M_NETVSC,
+	M_WAITOK, &txr->hn_tx_lock);
+#endif
 
 	txr->hn_tx_taskq = sc->hn_tx_taskq;
 	TASK_INIT(&txr->hn_start_task, 0, hn_start_taskfunc, txr);
@@ -2158,7 +2188,11 @@
 
 		/* All set, put it to list */
 		txd->flags |= HN_TXD_FLAG_ONLIST;
+#ifndef HN_USE_TXDESC_BUFRING
 		SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link);
+#else
+		buf_ring_enqueue(txr->hn_txdesc_br, txd);
+#endif
 	}
 	txr->hn_txdesc_avail = txr->hn_txdesc_cnt;
 
@@ -2191,35 +2225,47 @@
 }
 
 static void
+hn_txdesc_dmamap_destroy(struct hn_txdesc *txd)
+{
+	struct hn_tx_ring *txr = txd->txr;
+
+	KASSERT(txd->m == NULL, ("still has mbuf installed"));
+	KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("still dma mapped"));
+
+	bus_dmamap_unload(txr->hn_tx_rndis_dtag, txd->rndis_msg_dmap);
+	bus_dmamem_free(txr->hn_tx_rndis_dtag, txd->rndis_msg,
+	txd->rndis_msg_dmap);
+	bus_dmamap_destroy(txr->hn_tx_data_dtag, txd->data_dmap);
+}
+
+static void
 hn_destroy_tx_ring(struct hn_tx_ring *txr)
 {
 	struct hn_txdesc *txd;
 
 	if (txr->hn_txdesc == NULL)
 		return;
 
+#ifndef HN_USE_TXDESC_BUFRING
 	while ((txd = SLIST_FIRST(&txr->hn_txlist)) != NULL) {
-		KASSERT(txd->m == NULL, ("still has mbuf installed"));
-		KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0,
-		("still dma mapped"));
 		SLIST_REMOVE_HEAD(&txr->hn_txlist, link);
-
-		bus_dmamap_unload(txr->hn_tx_rndis_dtag,
-		txd->rndis_msg_dmap);
-		bus_dmamem_free(txr->hn_tx_rndis_dtag,
-		txd->rndis_msg, txd->rndis_msg_dmap);
-
-		bus_dmamap_destroy(txr->hn_tx_data_dtag, txd->data_dmap);
+		hn_txdesc_dmamap_destroy(txd);
 	}
+#else
+	while ((txd = buf_ring_dequeue_sc(txr->hn_txdesc_br)) != NULL)
+		hn_txdesc_dmamap_destroy(txd);
+#endif
 
 	if (txr->hn_tx_data_

[Differential] [Closed] D5282: hyperv/hn: Use non-fast taskqueue for transmission

2016-02-17 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295746: hyperv/hn: Use non-fast taskqueue for transmission 
(authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5282?vs=13307&id=13404#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5282?vs=13307&id=13404

REVISION DETAIL
  https://reviews.freebsd.org/D5282

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

CHANGE DETAILS
  diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c 
b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  --- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  +++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  @@ -368,7 +368,7 @@
sc->hn_direct_tx_size = hn_direct_tx_size;
   
if (hn_tx_taskq == NULL) {
  - sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
  + sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
taskqueue_thread_enqueue, &sc->hn_tx_taskq);
taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx",
device_get_nameunit(dev));
  @@ -2178,7 +2178,7 @@
if (!hn_share_tx_taskq)
return;
   
  - hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
  + hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
taskqueue_thread_enqueue, &hn_tx_taskq);
taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx");
   }

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -368,7 +368,7 @@
 	sc->hn_direct_tx_size = hn_direct_tx_size;
 
 	if (hn_tx_taskq == NULL) {
-		sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
+		sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
 		taskqueue_thread_enqueue, &sc->hn_tx_taskq);
 		taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx",
 		device_get_nameunit(dev));
@@ -2178,7 +2178,7 @@
 	if (!hn_share_tx_taskq)
 		return;
 
-	hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
+	hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
 	taskqueue_thread_enqueue, &hn_tx_taskq);
 	taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx");
 }

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"

[Differential] [Closed] D5276: hyperv/hn: Use taskqueue_enqueue()

2016-02-17 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295745: hyperv/hn: Use taskqueue_enqueue() (authored by 
sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5276?vs=13288&id=13403#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5276?vs=13288&id=13403

REVISION DETAIL
  https://reviews.freebsd.org/D5276

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

CHANGE DETAILS
  diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c 
b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  --- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  +++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  @@ -1549,7 +1549,7 @@
return;
}
   do_sched:
  - taskqueue_enqueue_fast(sc->hn_tx_taskq, &sc->hn_start_task);
  + taskqueue_enqueue(sc->hn_tx_taskq, &sc->hn_start_task);
   }
   
   static void
  @@ -1566,10 +1566,8 @@
atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE);
sched = hn_start_locked(ifp, sc->hn_direct_tx_size);
NV_UNLOCK(sc);
  - if (sched) {
  - taskqueue_enqueue_fast(sc->hn_tx_taskq,
  - &sc->hn_start_task);
  - }
  + if (sched)
  + taskqueue_enqueue(sc->hn_tx_taskq, &sc->hn_start_task);
} else {
   do_sched:
/*
  @@ -1579,7 +1577,7 @@
 * races.
 */
atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE);
  - taskqueue_enqueue_fast(sc->hn_tx_taskq, &sc->hn_txeof_task);
  + taskqueue_enqueue(sc->hn_tx_taskq, &sc->hn_txeof_task);
}
   }

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -1549,7 +1549,7 @@
 			return;
 	}
 do_sched:
-	taskqueue_enqueue_fast(sc->hn_tx_taskq, &sc->hn_start_task);
+	taskqueue_enqueue(sc->hn_tx_taskq, &sc->hn_start_task);
 }
 
 static void
@@ -1566,10 +1566,8 @@
 		atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE);
 		sched = hn_start_locked(ifp, sc->hn_direct_tx_size);
 		NV_UNLOCK(sc);
-		if (sched) {
-			taskqueue_enqueue_fast(sc->hn_tx_taskq,
-			&sc->hn_start_task);
-		}
+		if (sched)
+			taskqueue_enqueue(sc->hn_tx_taskq, &sc->hn_start_task);
 	} else {
 do_sched:
 		/*
@@ -1579,7 +1577,7 @@
 		 * races.
 		 */
 		atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE);
-		taskqueue_enqueue_fast(sc->hn_tx_taskq, &sc->hn_txeof_task);
+		taskqueue_enqueue(sc->hn_tx_taskq, &sc->hn_txeof_task);
 	}
 }
 

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"

[Differential] [Closed] D5275: hyperv/hn: Split RX ring data structure out of softc

2016-02-17 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295744: hyperv/hn: Split RX ring data structure out of softc 
(authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5275?vs=13287&id=13402#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5275?vs=13287&id=13402

REVISION DETAIL
  https://reviews.freebsd.org/D5275

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -275,12 +275,16 @@
 static int hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_tx_chimney_size_sysctl(SYSCTL_HANDLER_ARGS);
+static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS);
+static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_check_iplen(const struct mbuf *, int);
 static int hn_create_tx_ring(struct hn_softc *sc);
 static void hn_destroy_tx_ring(struct hn_softc *sc);
 static void hn_start_taskfunc(void *xsc, int pending);
 static void hn_txeof_taskfunc(void *xsc, int pending);
 static int hn_encap(struct hn_softc *, struct hn_txdesc *, struct mbuf **);
+static void hn_create_rx_data(struct hn_softc *sc);
+static void hn_destroy_rx_data(struct hn_softc *sc);
 
 static int
 hn_ifmedia_upd(struct ifnet *ifp __unused)
@@ -352,11 +356,6 @@
 #if __FreeBSD_version >= 1100045
 	int tso_maxlen;
 #endif
-#if defined(INET) || defined(INET6)
-#if __FreeBSD_version >= 1100095
-	int lroent_cnt;
-#endif
-#endif
 
 	sc = device_get_softc(dev);
 	if (sc == NULL) {
@@ -367,12 +366,6 @@
 	sc->hn_unit = unit;
 	sc->hn_dev = dev;
 	sc->hn_direct_tx_size = hn_direct_tx_size;
-	if (hn_trust_hosttcp)
-		sc->hn_trust_hcsum |= HN_TRUST_HCSUM_TCP;
-	if (hn_trust_hostudp)
-		sc->hn_trust_hcsum |= HN_TRUST_HCSUM_UDP;
-	if (hn_trust_hostip)
-		sc->hn_trust_hcsum |= HN_TRUST_HCSUM_IP;
 
 	if (hn_tx_taskq == NULL) {
 		sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
@@ -396,6 +389,8 @@
 	ifp = sc->hn_ifp = if_alloc(IFT_ETHER);
 	ifp->if_softc = sc;
 
+	hn_create_rx_data(sc);
+
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	ifp->if_dunit = unit;
 	ifp->if_dname = NETVSC_DEVNAME;
@@ -441,22 +436,6 @@
 		sc->hn_carrier = 1;
 	}
 
-#if defined(INET) || defined(INET6)
-#if __FreeBSD_version >= 1100095
-	lroent_cnt = hn_lro_entry_count;
-	if (lroent_cnt < TCP_LRO_ENTRIES)
-		lroent_cnt = TCP_LRO_ENTRIES;
-	tcp_lro_init_args(&sc->hn_lro, ifp, lroent_cnt, 0);
-	device_printf(dev, "LRO: entry count %d\n", lroent_cnt);
-#else
-	tcp_lro_init(&sc->hn_lro);
-	/* Driver private LRO settings */
-	sc->hn_lro.ifp = ifp;
-#endif
-	sc->hn_lro.lro_length_lim = HN_LRO_LENLIM_DEF;
-	sc->hn_lro.lro_ackcnt_lim = HN_LRO_ACKCNT_DEF;
-#endif	/* INET || INET6 */
-
 #if __FreeBSD_version >= 1100045
 	tso_maxlen = hn_tso_maxlen;
 	if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET)
@@ -491,44 +470,6 @@
 	ctx = device_get_sysctl_ctx(dev);
 	child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev));
 
-	SYSCTL_ADD_U64(ctx, child, OID_AUTO, "lro_queued",
-	CTLFLAG_RW, &sc->hn_lro.lro_queued, 0, "LRO queued");
-	SYSCTL_ADD_U64(ctx, child, OID_AUTO, "lro_flushed",
-	CTLFLAG_RW, &sc->hn_lro.lro_flushed, 0, "LRO flushed");
-	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "lro_tried",
-	CTLFLAG_RW, &sc->hn_lro_tried, "# of LRO tries");
-	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_length_lim",
-	CTLTYPE_UINT | CTLFLAG_RW, sc, 0, hn_lro_lenlim_sysctl, "IU",
-	"Max # of data bytes to be aggregated by LRO");
-	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_ackcnt_lim",
-	CTLTYPE_INT | CTLFLAG_RW, sc, 0, hn_lro_ackcnt_sysctl, "I",
-	"Max # of ACKs to be aggregated by LRO");
-	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hosttcp",
-	CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_TCP,
-	hn_trust_hcsum_sysctl, "I",
-	"Trust tcp segement verification on host side, "
-	"when csum info is missing");
-	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hostudp",
-	CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_UDP,
-	hn_trust_hcsum_sysctl, "I",
-	"Trust udp datagram verification on host side, "
-	"when csum info is missing");
-	SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hostip",
-	CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_IP,
-	hn_trust_hcsum_sysctl, "I",
-	"Trust ip packet verification on host side, "
-	"when csum info is missing");
-	SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "csum_ip",
-	CTLFLAG_

[Differential] [Closed] D5274: hyperv/hn: Change global tunable prefix to hw.hn

2016-02-17 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295743: hyperv/hn: Change global tunable prefix to hw.hn 
(authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5274?vs=13285&id=13401#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5274?vs=13285&id=13401

REVISION DETAIL
  https://reviews.freebsd.org/D5274

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
howard0su_gmail.com, honzhan_microsoft.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -205,41 +205,57 @@
 
 int hv_promisc_mode = 0;/* normal mode by default */
 
+SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD, NULL, "Hyper-V network interface");
+
 /* Trust tcp segements verification on host side. */
 static int hn_trust_hosttcp = 1;
-TUNABLE_INT("dev.hn.trust_hosttcp", &hn_trust_hosttcp);
+SYSCTL_INT(_hw_hn, OID_AUTO, trust_hosttcp, CTLFLAG_RDTUN,
+&hn_trust_hosttcp, 0,
+"Trust tcp segement verification on host side, "
+"when csum info is missing (global setting)");
 
 /* Trust udp datagrams verification on host side. */
 static int hn_trust_hostudp = 1;
-TUNABLE_INT("dev.hn.trust_hostudp", &hn_trust_hostudp);
+SYSCTL_INT(_hw_hn, OID_AUTO, trust_hostudp, CTLFLAG_RDTUN,
+&hn_trust_hostudp, 0,
+"Trust udp datagram verification on host side, "
+"when csum info is missing (global setting)");
 
 /* Trust ip packets verification on host side. */
 static int hn_trust_hostip = 1;
-TUNABLE_INT("dev.hn.trust_hostip", &hn_trust_hostip);
+SYSCTL_INT(_hw_hn, OID_AUTO, trust_hostip, CTLFLAG_RDTUN,
+&hn_trust_hostip, 0,
+"Trust ip packet verification on host side, "
+"when csum info is missing (global setting)");
 
 #if __FreeBSD_version >= 1100045
 /* Limit TSO burst size */
 static int hn_tso_maxlen = 0;
-TUNABLE_INT("dev.hn.tso_maxlen", &hn_tso_maxlen);
+SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN,
+&hn_tso_maxlen, 0, "TSO burst limit");
 #endif
 
 /* Limit chimney send size */
 static int hn_tx_chimney_size = 0;
-TUNABLE_INT("dev.hn.tx_chimney_size", &hn_tx_chimney_size);
+SYSCTL_INT(_hw_hn, OID_AUTO, tx_chimney_size, CTLFLAG_RDTUN,
+&hn_tx_chimney_size, 0, "Chimney send packet size limit");
 
 /* Limit the size of packet for direct transmission */
 static int hn_direct_tx_size = HN_DIRECT_TX_SIZE_DEF;
-TUNABLE_INT("dev.hn.direct_tx_size", &hn_direct_tx_size);
+SYSCTL_INT(_hw_hn, OID_AUTO, direct_tx_size, CTLFLAG_RDTUN,
+&hn_direct_tx_size, 0, "Size of the packet for direct transmission");
 
 #if defined(INET) || defined(INET6)
 #if __FreeBSD_version >= 1100095
 static int hn_lro_entry_count = HN_LROENT_CNT_DEF;
-TUNABLE_INT("dev.hn.lro_entry_count", &hn_lro_entry_count);
+SYSCTL_INT(_hw_hn, OID_AUTO, lro_entry_count, CTLFLAG_RDTUN,
+&hn_lro_entry_count, 0, "LRO entry count");
 #endif
 #endif
 
 static int hn_share_tx_taskq = 0;
-TUNABLE_INT("hw.hn.share_tx_taskq", &hn_share_tx_taskq);
+SYSCTL_INT(_hw_hn, OID_AUTO, share_tx_taskq, CTLFLAG_RDTUN,
+&hn_share_tx_taskq, 0, "Enable shared TX taskqueue");
 
 static struct taskqueue	*hn_tx_taskq;
 
@@ -541,48 +557,6 @@
 	"Always schedule transmission "
 	"instead of doing direct transmission");
 
-	if (unit == 0) {
-		struct sysctl_ctx_list *dc_ctx;
-		struct sysctl_oid_list *dc_child;
-		devclass_t dc;
-
-		/*
-		 * Add sysctl nodes for devclass
-		 */
-		dc = device_get_devclass(dev);
-		dc_ctx = devclass_get_sysctl_ctx(dc);
-		dc_child = SYSCTL_CHILDREN(devclass_get_sysctl_tree(dc));
-
-		SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "trust_hosttcp",
-		CTLFLAG_RD, &hn_trust_hosttcp, 0,
-		"Trust tcp segement verification on host side, "
-		"when csum info is missing (global setting)");
-		SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "trust_hostudp",
-		CTLFLAG_RD, &hn_trust_hostudp, 0,
-		"Trust udp datagram verification on host side, "
-		"when csum info is missing (global setting)");
-		SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "trust_hostip",
-		CTLFLAG_RD, &hn_trust_hostip, 0,
-		"Trust ip packet verification on host side, "
-		"when csum info is missing (global setting)");
-		SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "tx_chimney_size",
-		CTLFLAG_RD, &hn_tx_chimney_size, 0,
-		"Chimney send packet size limit");
-#if __FreeBSD_version >= 1100045
-		SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "tso_maxlen",
-		CTLFLAG_RD, &hn_tso_maxlen, 0, "TSO burst limit");
-#endif
-		SYSCTL_ADD_INT(dc_ctx, dc_child, OID_AUTO, "direct_tx_size",
-		CTLFLAG_RD, &hn_direct_tx_

[Differential] [Closed] D5273: hyperv/hn: Always do transmission scheduling.

2016-02-17 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295742: hyperv/hn: Always do transmission scheduling. 
(authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5273?vs=13284&id=13400#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5273?vs=13284&id=13400

REVISION DETAIL
  https://reviews.freebsd.org/D5273

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

CHANGE DETAILS
  diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c 
b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  --- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  +++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  @@ -465,6 +465,13 @@
hn_tx_chimney_size < sc->hn_tx_chimney_max)
sc->hn_tx_chimney_size = hn_tx_chimney_size;
   
  + /*
  +  * Always schedule transmission instead of trying
  +  * to do direct transmission.  This one gives the
  +  * best performance so far.
  +  */
  + sc->hn_sched_tx = 1;
  +
ctx = device_get_sysctl_ctx(dev);
child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev));

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -465,6 +465,13 @@
 	hn_tx_chimney_size < sc->hn_tx_chimney_max)
 		sc->hn_tx_chimney_size = hn_tx_chimney_size;
 
+	/*
+	 * Always schedule transmission instead of trying
+	 * to do direct transmission.  This one gives the
+	 * best performance so far.
+	 */
+	sc->hn_sched_tx = 1;
+
 	ctx = device_get_sysctl_ctx(dev);
 	child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev));
 

___
freebsd-virtualization@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"

[Differential] [Closed] D5272: hyperv/hn: Add option to allow sharing TX taskq between hn instances

2016-02-17 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295741: hyperv/hn: Add option to allow sharing TX taskq 
between hn instances (authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5272?vs=13283&id=13399#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5272?vs=13283&id=13399

REVISION DETAIL
  https://reviews.freebsd.org/D5272

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

CHANGE DETAILS
  diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c 
b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  --- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  +++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  @@ -238,6 +238,11 @@
   #endif
   #endif
   
  +static int hn_share_tx_taskq = 0;
  +TUNABLE_INT("hw.hn.share_tx_taskq", &hn_share_tx_taskq);
  +
  +static struct taskqueue  *hn_tx_taskq;
  +
   /*
* Forward declarations
*/
  @@ -353,10 +358,14 @@
if (hn_trust_hostip)
sc->hn_trust_hcsum |= HN_TRUST_HCSUM_IP;
   
  - sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
  - taskqueue_thread_enqueue, &sc->hn_tx_taskq);
  - taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx",
  - device_get_nameunit(dev));
  + if (hn_tx_taskq == NULL) {
  + sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
  + taskqueue_thread_enqueue, &sc->hn_tx_taskq);
  + taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx",
  + device_get_nameunit(dev));
  + } else {
  + sc->hn_tx_taskq = hn_tx_taskq;
  + }
TASK_INIT(&sc->hn_start_task, 0, hn_start_taskfunc, sc);
TASK_INIT(&sc->hn_txeof_task, 0, hn_txeof_taskfunc, sc);
   
  @@ -602,7 +611,8 @@
   
taskqueue_drain(sc->hn_tx_taskq, &sc->hn_start_task);
taskqueue_drain(sc->hn_tx_taskq, &sc->hn_txeof_task);
  - taskqueue_free(sc->hn_tx_taskq);
  + if (sc->hn_tx_taskq != hn_tx_taskq)
  + taskqueue_free(sc->hn_tx_taskq);
   
ifmedia_removeall(&sc->hn_media);
   #if defined(INET) || defined(INET6)
  @@ -2039,6 +2049,28 @@
NV_UNLOCK(sc);
   }
   
  +static void
  +hn_tx_taskq_create(void *arg __unused)
  +{
  + if (!hn_share_tx_taskq)
  + return;
  +
  + hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
  + taskqueue_thread_enqueue, &hn_tx_taskq);
  + taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx");
  +}
  +SYSINIT(hn_txtq_create, SI_SUB_DRIVERS, SI_ORDER_FIRST,
  +hn_tx_taskq_create, NULL);
  +
  +static void
  +hn_tx_taskq_destroy(void *arg __unused)
  +{
  + if (hn_tx_taskq != NULL)
  + taskqueue_free(hn_tx_taskq);
  +}
  +SYSUNINIT(hn_txtq_destroy, SI_SUB_DRIVERS, SI_ORDER_FIRST,
  +hn_tx_taskq_destroy, NULL);
  +
   static device_method_t netvsc_methods[] = {
   /* Device interface */
   DEVMETHOD(device_probe, netvsc_probe),

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -238,6 +238,11 @@
 #endif
 #endif
 
+static int hn_share_tx_taskq = 0;
+TUNABLE_INT("hw.hn.share_tx_taskq", &hn_share_tx_taskq);
+
+static struct taskqueue	*hn_tx_taskq;
+
 /*
  * Forward declarations
  */
@@ -353,10 +358,14 @@
 	if (hn_trust_hostip)
 		sc->hn_trust_hcsum |= HN_TRUST_HCSUM_IP;
 
-	sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
-	taskqueue_thread_enqueue, &sc->hn_tx_taskq);
-	taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx",
-	device_get_nameunit(dev));
+	if (hn_tx_taskq == NULL) {
+		sc->hn_tx_taskq = taskqueue_create_fast("hn_tx", M_WAITOK,
+		taskqueue_thread_enqueue, &sc->hn_tx_taskq);
+		taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, "%s tx",
+		device_get_nameunit(dev));
+	} else {
+		sc->hn_tx_taskq = hn_tx_taskq;
+	}
 	TASK_INIT(&sc->hn_start_task, 0, hn_start_taskfunc, sc);
 	TASK_INIT(&sc->hn_txeof_task, 0, hn_txeof_taskfunc, sc);
 
@@ -602,7 +611,8 @@
 
 	taskqueue_drain(sc->hn_tx_taskq, &sc->hn_start_task);
 	taskqueue_drain(sc->hn_tx_taskq, &sc->hn_txeof_task);
-	taskqueue_free(sc->hn_tx_taskq);
+	if (sc->hn_tx_taskq != hn_tx_taskq)
+		taskqueue_free(sc->hn_tx_taskq);
 
 	ifmedia_removeall(&sc->hn_media);
 #if defined(INET) || defined(INET6)
@@ -2039,6 +2049,28 @@
 	NV_UNLOCK(sc);
 }
 
+static void
+hn_tx_taskq_create(void *arg __unused)
+{
+	if (!hn_share_tx_taskq)
+		return;
+
+	hn_tx_taskq = taskqueue_create_fast("hn_tx", M_

[Differential] [Closed] D5185: tcp/lro: Allow network drivers to set the limit for TCP ACK/data segment aggregation limit

2016-02-17 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295739: tcp/lro: Allow drivers to set the TCP ACK/data 
segment aggregation limit (authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5185?vs=13282&id=13397#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5185?vs=13282&id=13397

REVISION DETAIL
  https://reviews.freebsd.org/D5185

AFFECTED FILES
  head/sys/netinet/tcp_lro.c
  head/sys/netinet/tcp_lro.h
  head/sys/sys/param.h

CHANGE DETAILS
  diff --git a/head/sys/sys/param.h b/head/sys/sys/param.h
  --- a/head/sys/sys/param.h
  +++ b/head/sys/sys/param.h
  @@ -58,7 +58,7 @@
*   in the range 5 to 9.
*/
   #undef __FreeBSD_version
  -#define __FreeBSD_version 1100098/* Master, propagated to newvers */
  +#define __FreeBSD_version 1100099/* Master, propagated to newvers */
   
   /*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
  diff --git a/head/sys/netinet/tcp_lro.h b/head/sys/netinet/tcp_lro.h
  --- a/head/sys/netinet/tcp_lro.h
  +++ b/head/sys/netinet/tcp_lro.h
  @@ -91,11 +91,16 @@
unsignedlro_cnt;
unsignedlro_mbuf_count;
unsignedlro_mbuf_max;
  + unsigned short  lro_ackcnt_lim; /* max # of aggregated ACKs */
  + unsignedlro_length_lim; /* max len of aggregated data */
   
struct lro_head lro_active;
struct lro_head lro_free;
   };
   
  +#define  TCP_LRO_LENGTH_MAX  65535
  +#define  TCP_LRO_ACKCNT_MAX  65535   /* unlimited */
  +
   int tcp_lro_init(struct lro_ctrl *);
   int tcp_lro_init_args(struct lro_ctrl *, struct ifnet *, unsigned, unsigned);
   void tcp_lro_free(struct lro_ctrl *);
  diff --git a/head/sys/netinet/tcp_lro.c b/head/sys/netinet/tcp_lro.c
  --- a/head/sys/netinet/tcp_lro.c
  +++ b/head/sys/netinet/tcp_lro.c
  @@ -88,6 +88,8 @@
lc->lro_mbuf_count = 0;
lc->lro_mbuf_max = lro_mbufs;
lc->lro_cnt = lro_entries;
  + lc->lro_ackcnt_lim = TCP_LRO_ACKCNT_MAX;
  + lc->lro_length_lim = TCP_LRO_LENGTH_MAX;
lc->ifp = ifp;
SLIST_INIT(&lc->lro_free);
SLIST_INIT(&lc->lro_active);
  @@ -610,7 +612,7 @@
}
   
/* Flush now if appending will result in overflow. */
  - if (le->p_len > (65535 - tcp_data_len)) {
  + if (le->p_len > (lc->lro_length_lim - tcp_data_len)) {
SLIST_REMOVE(&lc->lro_active, le, lro_entry, next);
tcp_lro_flush(lc, le);
break;
  @@ -648,6 +650,15 @@
   
if (tcp_data_len == 0) {
m_freem(m);
  + /*
  +  * Flush this LRO entry, if this ACK should not
  +  * be further delayed.
  +  */
  + if (le->append_cnt >= lc->lro_ackcnt_lim) {
  + SLIST_REMOVE(&lc->lro_active, le, lro_entry,
  + next);
  + tcp_lro_flush(lc, le);
  + }
return (0);
}
   
  @@ -668,7 +679,7 @@
 * If a possible next full length packet would cause an
 * overflow, pro-actively flush now.
 */
  - if (le->p_len > (65535 - lc->ifp->if_mtu)) {
  + if (le->p_len > (lc->lro_length_lim - lc->ifp->if_mtu)) {
SLIST_REMOVE(&lc->lro_active, le, lro_entry, next);
tcp_lro_flush(lc, le);
} else

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
honzhan_microsoft.com, howard0su_gmail.com, np, transport, hselasky, gallatin, 
adrian, network
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/sys/param.h b/head/sys/sys/param.h
--- a/head/sys/sys/param.h
+++ b/head/sys/sys/param.h
@@ -58,7 +58,7 @@
  *		in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1100098	/* Master, propagated to newvers */
+#define __FreeBSD_version 1100099	/* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
diff --git a/head/sys/netinet/tcp_lro.h b/head/sys/netinet/tcp_lro.h
--- a/head/sys/netinet/tcp_lro.h
+++ b/head/sys/netinet/tcp_lro.h
@@ -91,11 +91,16 @@
 	unsigned	lro_cnt;
 	unsigned	lro_mbuf_count;
 	unsigned	lro_mbuf_max;
+	unsigned short	lro_ackcnt_lim;		/* max # of aggregated ACKs */
+	unsigned 	lro_length_lim;		/* max len of aggregated data */
 
 	struct lro_head	lro_active;
 	struct lro_head	lro_free;
 };
 
+#define	TCP_LRO_LENGTH_MAX	65535
+#define	TCP_LRO_ACKCNT_MAX	65535		/* unlimited */
+
 int tcp_lro_init(struct lro_ctrl *);
 int tcp_lro_init_arg

[Differential] [Closed] D5175: hyperv/hn: Add an option to always do transmission scheduling

2016-02-04 Thread Phabricator
This revision was automatically updated to reflect the committed changes.
Closed by commit rS295306: hyperv/hn: Add an option to always do transmission 
scheduling (authored by sephe).

CHANGED PRIOR TO COMMIT
  https://reviews.freebsd.org/D5175?vs=12968&id=13040#toc

REPOSITORY
  rS FreeBSD src repository

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D5175?vs=12968&id=13040

REVISION DETAIL
  https://reviews.freebsd.org/D5175

AFFECTED FILES
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

CHANGE DETAILS
  diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c 
b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  --- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  +++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  @@ -534,6 +534,10 @@
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "direct_tx_size",
CTLFLAG_RW, &sc->hn_direct_tx_size, 0,
"Size of the packet for direct transmission");
  + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "sched_tx",
  + CTLFLAG_RW, &sc->hn_sched_tx, 0,
  + "Always schedule transmission "
  + "instead of doing direct transmission");
   
if (unit == 0) {
struct sysctl_ctx_list *dc_ctx;
  @@ -1602,26 +1606,31 @@
   static void
   hn_start(struct ifnet *ifp)
   {
  - hn_softc_t *sc;
  + struct hn_softc *sc = ifp->if_softc;
  +
  + if (sc->hn_sched_tx)
  + goto do_sched;
   
  - sc = ifp->if_softc;
if (NV_TRYLOCK(sc)) {
int sched;
   
sched = hn_start_locked(ifp, sc->hn_direct_tx_size);
NV_UNLOCK(sc);
if (!sched)
return;
}
  +do_sched:
taskqueue_enqueue_fast(sc->hn_tx_taskq, &sc->hn_start_task);
   }
   
   static void
   hn_start_txeof(struct ifnet *ifp)
   {
  - hn_softc_t *sc;
  + struct hn_softc *sc = ifp->if_softc;
  +
  + if (sc->hn_sched_tx)
  + goto do_sched;
   
  - sc = ifp->if_softc;
if (NV_TRYLOCK(sc)) {
int sched;
   
  @@ -1633,6 +1642,7 @@
&sc->hn_start_task);
}
} else {
  +do_sched:
/*
 * Release the OACTIVE earlier, with the hope, that
 * others could catch up.  The task will clear the
  diff --git a/head/sys/dev/hyperv/netvsc/hv_net_vsc.h 
b/head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  --- a/head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  +++ b/head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  @@ -1023,6 +1023,7 @@
int hn_txdesc_avail;
int hn_txeof;
   
  + int hn_sched_tx;
int hn_direct_tx_size;
struct taskqueue *hn_tx_taskq;
struct task hn_start_task;

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, 
howard0su_gmail.com, adrian, network, honzhan_microsoft.com
Cc: freebsd-virtualization-list, freebsd-net-list
diff --git a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
--- a/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -534,6 +534,10 @@
 	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "direct_tx_size",
 	CTLFLAG_RW, &sc->hn_direct_tx_size, 0,
 	"Size of the packet for direct transmission");
+	SYSCTL_ADD_INT(ctx, child, OID_AUTO, "sched_tx",
+	CTLFLAG_RW, &sc->hn_sched_tx, 0,
+	"Always schedule transmission "
+	"instead of doing direct transmission");
 
 	if (unit == 0) {
 		struct sysctl_ctx_list *dc_ctx;
@@ -1602,26 +1606,31 @@
 static void
 hn_start(struct ifnet *ifp)
 {
-	hn_softc_t *sc;
+	struct hn_softc *sc = ifp->if_softc;
+
+	if (sc->hn_sched_tx)
+		goto do_sched;
 
-	sc = ifp->if_softc;
 	if (NV_TRYLOCK(sc)) {
 		int sched;
 
 		sched = hn_start_locked(ifp, sc->hn_direct_tx_size);
 		NV_UNLOCK(sc);
 		if (!sched)
 			return;
 	}
+do_sched:
 	taskqueue_enqueue_fast(sc->hn_tx_taskq, &sc->hn_start_task);
 }
 
 static void
 hn_start_txeof(struct ifnet *ifp)
 {
-	hn_softc_t *sc;
+	struct hn_softc *sc = ifp->if_softc;
+
+	if (sc->hn_sched_tx)
+		goto do_sched;
 
-	sc = ifp->if_softc;
 	if (NV_TRYLOCK(sc)) {
 		int sched;
 
@@ -1633,6 +1642,7 @@
 			&sc->hn_start_task);
 		}
 	} else {
+do_sched:
 		/*
 		 * Release the OACTIVE earlier, with the hope, that
 		 * others could catch up.  The task will clear the
diff --git a/head/sys/dev/hyperv/netvsc/hv_net_vsc.h b/head/sys/dev/hyperv/netvsc/hv_net_vsc.h
--- a/head/sys/dev/hyperv/netvsc/hv_net_vsc.h
+++ b/head/sys/dev/hyperv/netvsc/hv_net_vsc.h
@@ -1023,6 +1023,7 @@
 	int		hn_txdesc_avail;
 	int		hn_txeof;
 
+	int		hn_sched_tx;
 	int		hn_direct_tx_size;
 	struct taskqueue *hn_tx_taskq;
 	struct task	hn_start_task;

___
freebsd-virtua