From owner-svn-soc-all@freebsd.org Mon Jul 18 09:05:51 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B1A92B9C59B for ; Mon, 18 Jul 2016 09:05:51 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A0B811D18 for ; Mon, 18 Jul 2016 09:05:51 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I95p17092552 for ; Mon, 18 Jul 2016 09:05:51 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I95oNQ092246 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:05:50 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:05:50 GMT Message-Id: <201607180905.u6I95oNQ092246@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306407 - in soc2016/vincenzo/head/sys: dev/netmap modules/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:05:51 -0000 Author: vincenzo Date: Mon Jul 18 09:05:49 2016 New Revision: 306407 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306407 Log: freebsd: netmap Makefile: add -DINET to CFLAGS Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c soc2016/vincenzo/head/sys/modules/netmap/Makefile Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 08:20:31 2016 (r306406) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:05:49 2016 (r306407) @@ -87,6 +87,10 @@ #error "No support for on-device CSB" #endif +#ifndef INET +#error "INET not defined, cannot support offloadings" +#endif + //#define DEBUG #ifdef DEBUG #define DBG(x) x Modified: soc2016/vincenzo/head/sys/modules/netmap/Makefile ============================================================================== --- soc2016/vincenzo/head/sys/modules/netmap/Makefile Mon Jul 18 08:20:31 2016 (r306406) +++ soc2016/vincenzo/head/sys/modules/netmap/Makefile Mon Jul 18 09:05:49 2016 (r306407) @@ -8,7 +8,7 @@ .PATH: ${.CURDIR}/../../dev/netmap .PATH.h: ${.CURDIR}/../../net -CFLAGS += -I${.CURDIR}/../../ +CFLAGS += -I${.CURDIR}/../../ -D INET KMOD = netmap SRCS = device_if.h bus_if.h pci_if.h opt_netmap.h SRCS += netmap.c netmap.h netmap_kern.h From owner-svn-soc-all@freebsd.org Mon Jul 18 09:06:01 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93F4FB9C5BA for ; Mon, 18 Jul 2016 09:06:01 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 851911D31 for ; Mon, 18 Jul 2016 09:06:01 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I961ax095330 for ; Mon, 18 Jul 2016 09:06:01 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I960YY094997 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:06:00 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:06:00 GMT Message-Id: <201607180906.u6I960YY094997@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306408 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:06:01 -0000 Author: vincenzo Date: Mon Jul 18 09:06:00 2016 New Revision: 306408 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306408 Log: freebsd: ptnet_vnet_hdr true by default Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:05:49 2016 (r306407) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:06:00 2016 (r306408) @@ -99,7 +99,7 @@ #endif /* !DEBUG */ /* Tunable parameters. */ -static bool ptnet_vnet_hdr = false; +static bool ptnet_vnet_hdr = true; struct ptnet_softc; @@ -1682,7 +1682,7 @@ continue; } } - RD(1, "%s: [csum_flags %lX] vnet hdr: flags %x " + ND(1, "%s: [csum_flags %lX] vnet hdr: flags %x " "csum_start %u csum_ofs %u hdr_len = %u " "gso_size %u gso_type %x", __func__, mhead->m_pkthdr.csum_flags, vh->flags, @@ -1908,7 +1908,7 @@ head = ptnet_rx_discard(kring, head); continue; } - RD(1, "%s: vnet hdr: flags %x csum_start %u " + ND(1, "%s: vnet hdr: flags %x csum_start %u " "csum_ofs %u hdr_len = %u gso_size %u " "gso_type %x", __func__, vh->flags, vh->csum_start, vh->csum_offset, vh->hdr_len, From owner-svn-soc-all@freebsd.org Mon Jul 18 09:06:11 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0EFAFB9C5D2 for ; Mon, 18 Jul 2016 09:06:11 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 028541D46 for ; Mon, 18 Jul 2016 09:06:11 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I96AH5098155 for ; Mon, 18 Jul 2016 09:06:10 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I96ATb097819 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:06:10 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:06:10 GMT Message-Id: <201607180906.u6I96ATb097819@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306409 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:06:11 -0000 Author: vincenzo Date: Mon Jul 18 09:06:09 2016 New Revision: 306409 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306409 Log: freebsd: use TUNABLE_INT macro to change ptnet_vnet_hdr Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:06:00 2016 (r306408) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:06:09 2016 (r306409) @@ -99,7 +99,8 @@ #endif /* !DEBUG */ /* Tunable parameters. */ -static bool ptnet_vnet_hdr = true; +static int ptnet_vnet_hdr = 0; +TUNABLE_INT("hw.ptnet.vnet_hdr", &ptnet_vnet_hdr); struct ptnet_softc; From owner-svn-soc-all@freebsd.org Mon Jul 18 09:06:21 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 571FBB9C5FB for ; Mon, 18 Jul 2016 09:06:21 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 462891D5C for ; Mon, 18 Jul 2016 09:06:21 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I96LNg001127 for ; Mon, 18 Jul 2016 09:06:21 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I96KVo000697 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:06:20 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:06:20 GMT Message-Id: <201607180906.u6I96KVo000697@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306410 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:06:21 -0000 Author: vincenzo Date: Mon Jul 18 09:06:19 2016 New Revision: 306410 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306410 Log: freebsd: ptnet: add ptnet_vnet_hdr parameter Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c soc2016/vincenzo/head/sys/dev/netmap/netmap.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:06:09 2016 (r306409) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:06:19 2016 (r306410) @@ -98,9 +98,7 @@ #define DBG(x) #endif /* !DEBUG */ -/* Tunable parameters. */ -static int ptnet_vnet_hdr = 0; -TUNABLE_INT("hw.ptnet.vnet_hdr", &ptnet_vnet_hdr); +extern int ptnet_vnet_hdr; /* Tunable parameter */ struct ptnet_softc; Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/netmap.c Mon Jul 18 09:06:09 2016 (r306409) +++ soc2016/vincenzo/head/sys/dev/netmap/netmap.c Mon Jul 18 09:06:19 2016 (r306410) @@ -516,6 +516,9 @@ int netmap_generic_ringsize = 1024; int netmap_generic_rings = 1; +/* Let ptnet devices use virtio-net headers. */ +int ptnet_vnet_hdr = 0; + /* * SYSCTL calls are grouped between SYSBEGIN and SYSEND to be emulated * in some other operating systems @@ -543,6 +546,7 @@ SYSCTL_INT(_dev_netmap, OID_AUTO, generic_ringsize, CTLFLAG_RW, &netmap_generic_ringsize, 0 , ""); SYSCTL_INT(_dev_netmap, OID_AUTO, generic_rings, CTLFLAG_RW, &netmap_generic_rings, 0 , ""); SYSCTL_INT(_dev_netmap, OID_AUTO, generic_txqdisc, CTLFLAG_RW, &netmap_generic_txqdisc, 0 , ""); +SYSCTL_INT(_dev_netmap, OID_AUTO, ptnet_vnet_hdr, CTLFLAG_RW, &ptnet_vnet_hdr, 0 , ""); SYSEND; From owner-svn-soc-all@freebsd.org Mon Jul 18 09:06:52 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B7276B9C65D for ; Mon, 18 Jul 2016 09:06:52 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A6D641DA1 for ; Mon, 18 Jul 2016 09:06:52 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I96q9S009395 for ; Mon, 18 Jul 2016 09:06:52 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I96qqg009194 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:06:52 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:06:52 GMT Message-Id: <201607180906.u6I96qqg009194@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306411 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:06:52 -0000 Author: vincenzo Date: Mon Jul 18 09:06:51 2016 New Revision: 306411 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306411 Log: freebsd: ptnet tasks: use DBG() Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:06:19 2016 (r306410) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:06:51 2016 (r306411) @@ -2049,7 +2049,7 @@ { struct ptnet_queue *pq = context; - RD(1, "%s: pq #%u\n", __func__, pq->kring_id); + DBG(RD(1, "%s: pq #%u\n", __func__, pq->kring_id)); ptnet_rx_eof(pq); } @@ -2058,7 +2058,7 @@ { struct ptnet_queue *pq = context; - RD(1, "%s: pq #%u\n", __func__, pq->kring_id); + DBG(RD(1, "%s: pq #%u\n", __func__, pq->kring_id)); ptnet_drain_transmit_queue(pq); } From owner-svn-soc-all@freebsd.org Mon Jul 18 09:07:11 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9CD42B9C6B6 for ; Mon, 18 Jul 2016 09:07:11 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8B6411DE4 for ; Mon, 18 Jul 2016 09:07:11 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I97BEY014583 for ; Mon, 18 Jul 2016 09:07:11 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I97A93014355 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:07:10 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:07:10 GMT Message-Id: <201607180907.u6I97A93014355@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306412 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:07:11 -0000 Author: vincenzo Date: Mon Jul 18 09:07:10 2016 New Revision: 306412 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306412 Log: netmap_virt: add PTNET_IO_VNET_HDR_LEN register Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h Mon Jul 18 09:06:51 2016 (r306411) +++ soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h Mon Jul 18 09:07:10 2016 (r306412) @@ -230,7 +230,8 @@ #define PTNET_IO_NUM_RX_RINGS 40 #define PTNET_IO_NUM_TX_SLOTS 44 #define PTNET_IO_NUM_RX_SLOTS 48 -#define PTNET_IO_END 52 +#define PTNET_IO_VNET_HDR_LEN 52 +#define PTNET_IO_END 56 #define PTNET_IO_KICK_BASE 128 #define PTNET_IO_MASK 0xff From owner-svn-soc-all@freebsd.org Mon Jul 18 09:07:21 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3C992B9C6EF for ; Mon, 18 Jul 2016 09:07:21 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2E2511DFB for ; Mon, 18 Jul 2016 09:07:21 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I97Lho017104 for ; Mon, 18 Jul 2016 09:07:21 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I97KiB016947 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:07:20 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:07:20 GMT Message-Id: <201607180907.u6I97KiB016947@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306413 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:07:21 -0000 Author: vincenzo Date: Mon Jul 18 09:07:19 2016 New Revision: 306413 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306413 Log: freebsd: ptnet: introduce ptnet_update_vnet_hdr() Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:07:10 2016 (r306412) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:07:19 2016 (r306413) @@ -130,6 +130,7 @@ /* Mirror of PTFEAT register. */ uint32_t ptfeatures; + unsigned int vnet_hdr_len; /* Reference counter used to track the regif operations on the * passed-through netmap port. */ @@ -184,6 +185,7 @@ static int ptnet_nm_krings_create(struct netmap_adapter *na); static void ptnet_nm_krings_delete(struct netmap_adapter *na); static void ptnet_nm_dtor(struct netmap_adapter *na); +static void ptnet_update_vnet_hdr(struct ptnet_softc *sc); static int ptnet_nm_register(struct netmap_adapter *na, int onoff); static int ptnet_nm_txsync(struct netmap_kring *kring, int flags); static int ptnet_nm_rxsync(struct netmap_kring *kring, int flags); @@ -436,9 +438,7 @@ /* If virtio-net header was negotiated, set the virt_hdr_len field in * the netmap adapter, to inform users that this netmap adapter requires * the application to deal with the headers. */ - if (sc->ptfeatures & NET_PTN_FEATURES_VNET_HDR) { - sc->ptna_nm->hwup.up.virt_hdr_len = PTNET_HDR_SIZE; - } + ptnet_update_vnet_hdr(sc); /* Initialize a separate pass-through netmap adapter that is going to * be used by this driver only, and so never exposed to netmap. We @@ -1047,6 +1047,14 @@ } \ } while (0) \ +static void +ptnet_update_vnet_hdr(struct ptnet_softc *sc) +{ + sc->vnet_hdr_len = ptnet_vnet_hdr ? PTNET_HDR_SIZE : 0; + sc->ptna_nm->hwup.up.virt_hdr_len = sc->vnet_hdr_len; + bus_write_4(sc->iomem, PTNET_IO_VNET_HDR_LEN, sc->vnet_hdr_len); +} + static int ptnet_nm_register(struct netmap_adapter *na, int onoff) { @@ -1082,6 +1090,9 @@ csb_notification_enable_all(sc, na, NR_RX, host_need_kick, 1); csb_notification_enable_all(sc, na, NR_RX, guest_need_kick, 1); + /* Set the virtio-net header length. */ + ptnet_update_vnet_hdr(sc); + /* Make sure the host adapter passed through is ready * for txsync/rxsync. */ ret = ptnet_nm_ptctl(ifp, NET_PARAVIRT_PTCTL_REGIF); @@ -1583,7 +1594,7 @@ ptnet_drain_transmit_queue(struct ptnet_queue *pq) { struct ptnet_softc *sc = pq->sc; - bool have_vnet_hdr = (sc->ptfeatures & NET_PTN_FEATURES_VNET_HDR); + bool have_vnet_hdr = sc->vnet_hdr_len; struct netmap_adapter *na = &sc->ptna_dr.hwup.up; struct ifnet *ifp = sc->ifp; unsigned int batch_count = 0; @@ -1848,7 +1859,7 @@ ptnet_rx_eof(struct ptnet_queue *pq) { struct ptnet_softc *sc = pq->sc; - bool have_vnet_hdr = (sc->ptfeatures & NET_PTN_FEATURES_VNET_HDR); + bool have_vnet_hdr = sc->vnet_hdr_len; struct ptnet_ring *ptring = pq->ptring; struct netmap_adapter *na = &sc->ptna_dr.hwup.up; struct netmap_kring *kring = na->rx_rings + pq->kring_id; @@ -2033,8 +2044,8 @@ if (!budget) { /* If we ran out of budget or the double-check found new * slots to process, schedule the taskqueue. */ - RD(1, "out of budget: resched h %u t %u\n", - head, ring->tail); + DBG(RD(1, "out of budget: resched h %u t %u\n", + head, ring->tail)); taskqueue_enqueue(pq->taskq, &pq->task); } } From owner-svn-soc-all@freebsd.org Mon Jul 18 09:07:44 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B9894B9C70A for ; Mon, 18 Jul 2016 09:07:44 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AAA741E15 for ; Mon, 18 Jul 2016 09:07:44 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I97ioa020146 for ; Mon, 18 Jul 2016 09:07:44 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I97iOh020004 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:07:44 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:07:44 GMT Message-Id: <201607180907.u6I97iOh020004@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306414 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:07:44 -0000 Author: vincenzo Date: Mon Jul 18 09:07:43 2016 New Revision: 306414 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306414 Log: freebsd: ptnet_transmit: add BPF support Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:07:19 2016 (r306413) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:07:43 2016 (r306414) @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -1743,6 +1744,10 @@ /* Consume the packet just processed. */ drbr_advance(ifp, pq->bufring); + + /* Copy the packet to listeners. */ + ETHER_BPF_MTAP(ifp, mhead); + m_freem(mhead); if (++batch_count == PTNET_TX_BATCH) { From owner-svn-soc-all@freebsd.org Mon Jul 18 09:07:53 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79B6FB9C726 for ; Mon, 18 Jul 2016 09:07:53 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6D1E01E2D for ; Mon, 18 Jul 2016 09:07:53 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I97rt8021661 for ; Mon, 18 Jul 2016 09:07:53 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I97qF6021580 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:07:52 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:07:52 GMT Message-Id: <201607180907.u6I97qF6021580@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306415 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:07:53 -0000 Author: vincenzo Date: Mon Jul 18 09:07:52 2016 New Revision: 306415 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306415 Log: netmap: default value for ptnet_vnet_hdr back to 1 Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap.c Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/netmap.c Mon Jul 18 09:07:43 2016 (r306414) +++ soc2016/vincenzo/head/sys/dev/netmap/netmap.c Mon Jul 18 09:07:52 2016 (r306415) @@ -516,8 +516,8 @@ int netmap_generic_ringsize = 1024; int netmap_generic_rings = 1; -/* Let ptnet devices use virtio-net headers. */ -int ptnet_vnet_hdr = 0; +/* Non-zero if ptnet devices are allowed to use virtio-net headers. */ +int ptnet_vnet_hdr = 1; /* * SYSCTL calls are grouped between SYSBEGIN and SYSEND to be emulated From owner-svn-soc-all@freebsd.org Mon Jul 18 09:08:04 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7F762B9C740 for ; Mon, 18 Jul 2016 09:08:04 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6C3641E41 for ; Mon, 18 Jul 2016 09:08:04 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I984xq022700 for ; Mon, 18 Jul 2016 09:08:04 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I983sa022606 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:08:03 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:08:03 GMT Message-Id: <201607180908.u6I983sa022606@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306416 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:08:04 -0000 Author: vincenzo Date: Mon Jul 18 09:08:03 2016 New Revision: 306416 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306416 Log: freebsd: ptnet_ring_update: generalize it, so that can be used by ptnet_rx_eof Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:07:52 2016 (r306415) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:08:03 2016 (r306416) @@ -1565,7 +1565,7 @@ static void ptnet_ring_update(struct ptnet_queue *pq, struct netmap_kring *kring, - unsigned int head) + unsigned int head, unsigned int sync_flags) { struct netmap_ring *ring = kring->ring; struct ptnet_ring *ptring = pq->ptring; @@ -1575,14 +1575,14 @@ * and head in the CSB. */ ring->head = ring->cur = head; - /* nm_txsync_prologue */ - kring->rcur = kring->rhead = ring->head; + /* Mimic nm_txsync_prologue/nm_rxsync_prologue. */ + kring->rcur = kring->rhead = head; ptnetmap_guest_write_kring_csb(ptring, kring->rcur, kring->rhead); /* Kick the host if needed. */ if (NM_ACCESS_ONCE(ptring->host_need_kick)) { - ptring->sync_flags = NAF_FORCE_RECLAIM; + ptring->sync_flags = sync_flags; bus_write_4(pq->sc->iomem, pq->kick, 0); } } @@ -1752,12 +1752,12 @@ if (++batch_count == PTNET_TX_BATCH) { batch_count = 0; - ptnet_ring_update(pq, kring, head); + ptnet_ring_update(pq, kring, head, NAF_FORCE_RECLAIM); } } if (batch_count) { - ptnet_ring_update(pq, kring, head); + ptnet_ring_update(pq, kring, head, NAF_FORCE_RECLAIM); } PTNET_Q_UNLOCK(pq); From owner-svn-soc-all@freebsd.org Mon Jul 18 09:08:17 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D5085B9C762 for ; Mon, 18 Jul 2016 09:08:17 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C65381E59 for ; Mon, 18 Jul 2016 09:08:17 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I98HJg024394 for ; Mon, 18 Jul 2016 09:08:17 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I98HS0024311 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:08:17 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:08:17 GMT Message-Id: <201607180908.u6I98HS0024311@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306417 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:08:17 -0000 Author: vincenzo Date: Mon Jul 18 09:08:16 2016 New Revision: 306417 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306417 Log: freebsd: ptnet_rx_eof: reuse ptnet_ring_update() function Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:08:03 2016 (r306416) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:08:16 2016 (r306417) @@ -2031,20 +2031,7 @@ /* Some packets have been pushed to the network stack. * We need to update the CSB to tell the host about the new * ring->cur and ring->head (RX buffer refill). */ - ring->head = ring->cur = head; - - /* Mimic rxsync_prologue */ - kring->rcur = ring->cur; - kring->rhead = ring->head; - - ptnetmap_guest_write_kring_csb(ptring, kring->rcur, - kring->rhead); - - /* Kick the host if needed. */ - if (NM_ACCESS_ONCE(ptring->host_need_kick)) { - ptring->sync_flags = NAF_FORCE_READ; - bus_write_4(sc->iomem, pq->kick, 0); - } + ptnet_ring_update(pq, kring, head, NAF_FORCE_READ); if (!budget) { /* If we ran out of budget or the double-check found new From owner-svn-soc-all@freebsd.org Mon Jul 18 09:08:47 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC3A0B9C779 for ; Mon, 18 Jul 2016 09:08:47 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A6F1D1E76 for ; Mon, 18 Jul 2016 09:08:47 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I98lOb031183 for ; Mon, 18 Jul 2016 09:08:47 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I98lt5030680 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:08:47 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:08:47 GMT Message-Id: <201607180908.u6I98lt5030680@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306418 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:08:47 -0000 Author: vincenzo Date: Mon Jul 18 09:08:46 2016 New Revision: 306418 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306418 Log: freebsd: ptnet_rx_eof: implement batching scheme Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:08:16 2016 (r306417) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:08:46 2016 (r306418) @@ -236,6 +236,7 @@ #define PTNET_BUF_RING_SIZE 4096 #define PTNET_RX_BUDGET 512 +#define PTNET_RX_BATCH 1 #define PTNET_TX_BATCH 64 #define PTNET_HDR_SIZE sizeof(struct virtio_net_hdr_mrg_rxbuf) #define PTNET_MAX_PKT_SIZE 65536 @@ -1751,8 +1752,8 @@ m_freem(mhead); if (++batch_count == PTNET_TX_BATCH) { - batch_count = 0; ptnet_ring_update(pq, kring, head, NAF_FORCE_RECLAIM); + batch_count = 0; } } @@ -1872,6 +1873,7 @@ unsigned int const lim = kring->nkr_num_slots - 1; unsigned int budget = PTNET_RX_BUDGET; unsigned int head = ring->head; + unsigned int batch_count = 0; struct ifnet *ifp = sc->ifp; PTNET_Q_LOCK(pq); @@ -2025,21 +2027,26 @@ (*ifp->if_input)(ifp, mhead); PTNET_Q_LOCK(pq); + if (++batch_count == PTNET_RX_BATCH) { + /* Some packets have been pushed to the network stack. + * We need to update the CSB to tell the host about the new + * ring->cur and ring->head (RX buffer refill). */ + ptnet_ring_update(pq, kring, head, NAF_FORCE_READ); + batch_count = 0; + } } while (--budget); escape: - if (head != ring->head) { - /* Some packets have been pushed to the network stack. - * We need to update the CSB to tell the host about the new - * ring->cur and ring->head (RX buffer refill). */ + if (batch_count) { ptnet_ring_update(pq, kring, head, NAF_FORCE_READ); - if (!budget) { - /* If we ran out of budget or the double-check found new - * slots to process, schedule the taskqueue. */ - DBG(RD(1, "out of budget: resched h %u t %u\n", - head, ring->tail)); - taskqueue_enqueue(pq->taskq, &pq->task); - } + } + + if (!budget) { + /* If we ran out of budget or the double-check found new + * slots to process, schedule the taskqueue. */ + DBG(RD(1, "out of budget: resched h %u t %u\n", + head, ring->tail)); + taskqueue_enqueue(pq->taskq, &pq->task); } PTNET_Q_UNLOCK(pq); From owner-svn-soc-all@freebsd.org Mon Jul 18 09:09:06 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C0286B9C799 for ; Mon, 18 Jul 2016 09:09:06 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B04B01E90 for ; Mon, 18 Jul 2016 09:09:06 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I996E4043561 for ; Mon, 18 Jul 2016 09:09:06 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I996No042811 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:09:06 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:09:06 GMT Message-Id: <201607180909.u6I996No042811@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306419 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:09:06 -0000 Author: vincenzo Date: Mon Jul 18 09:09:05 2016 New Revision: 306419 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306419 Log: freebsd: ptnet: implement a synchronization scheme for ifconfig down Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:08:46 2016 (r306418) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:05 2016 (r306419) @@ -196,7 +196,7 @@ static unsigned ptnet_rx_discard(struct netmap_kring *kring, unsigned int head); -static int ptnet_rx_eof(struct ptnet_queue *pq); +static void ptnet_rx_eof(struct ptnet_queue *pq); static void ptnet_rx_task(void *context, int pending); static device_method_t ptnet_methods[] = { @@ -857,6 +857,7 @@ { struct ifnet *ifp = sc->ifp; struct netmap_adapter *na_dr = &sc->ptna_dr.hwup.up; + int i; device_printf(sc->dev, "%s\n", __func__); @@ -864,7 +865,14 @@ return 0; /* nothing to do */ } - /* XXX Here we should wait for all TX and RX worker to finish. */ + /* Clear the driver-ready flag, and synchronize with all the queues, + * so that after this loop we are sure nobody is working anymore with + * the device. This scheme is taken from the vtnet driver. */ + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + for (i = 0; i < sc->num_rings; i++) { + PTNET_Q_LOCK(sc->queues + i); + PTNET_Q_UNLOCK(sc->queues + i); + } ptnet_nm_register(na_dr, 0 /* off */); @@ -874,8 +882,6 @@ } netmap_mem_deref(na_dr->nm_mem, na_dr); - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - return 0; } @@ -1196,10 +1202,6 @@ DBG(device_printf(sc->dev, "Tx interrupt #%d\n", pq->kring_id)); - if (!(sc->ifp->if_drv_flags & IFF_DRV_RUNNING)) { - return; - } - if (netmap_tx_irq(sc->ifp, pq->kring_id) != NM_IRQ_PASS) { return; } @@ -1220,10 +1222,6 @@ DBG(device_printf(sc->dev, "Rx interrupt #%d\n", pq->kring_id)); - if (!(sc->ifp->if_drv_flags & IFF_DRV_RUNNING)) { - return; - } - if (netmap_rx_irq(sc->ifp, pq->kring_id, &unused) != NM_IRQ_PASS) { return; } @@ -1592,6 +1590,8 @@ ((((_h) < (_k)->rtail) ? 0 : (_k)->nkr_num_slots) + \ (_k)->rtail - (_h)) < (_min) +/* This function may be called by the network stack, or by + * by the taskqueue thread. */ static int ptnet_drain_transmit_queue(struct ptnet_queue *pq) { @@ -1612,14 +1612,6 @@ int nmbuf_bytes; uint8_t *nmbuf; - if (unlikely(!(ifp->if_drv_flags & IFF_DRV_RUNNING))) { - RD(1, "Interface is down"); - return ENETDOWN; - } - - /* Here we may be called by the network stack, or by - * by the taskqueue thread. */ - if (!PTNET_Q_TRYLOCK(pq)) { /* We failed to acquire the lock, schedule the taskqueue. */ RD(1, "Deferring TX work"); @@ -1628,6 +1620,12 @@ return 0; } + if (unlikely(!(ifp->if_drv_flags & IFF_DRV_RUNNING))) { + PTNET_Q_UNLOCK(pq); + RD(1, "Interface is down"); + return ENETDOWN; + } + ptring = pq->ptring; kring = na->tx_rings + pq->kring_id; ring = kring->ring; @@ -1861,7 +1859,7 @@ return mtail; } -static int +static void ptnet_rx_eof(struct ptnet_queue *pq) { struct ptnet_softc *sc = pq->sc; @@ -1878,6 +1876,10 @@ PTNET_Q_LOCK(pq); + if (unlikely(!(ifp->if_drv_flags & IFF_DRV_RUNNING))) { + goto unlock; + } + kring->nr_kflags &= ~NKR_PENDINTR; do { @@ -2027,6 +2029,12 @@ (*ifp->if_input)(ifp, mhead); PTNET_Q_LOCK(pq); + if (unlikely(!(ifp->if_drv_flags & IFF_DRV_RUNNING))) { + /* The interface has gone down while we didn't + * have the lock. Stop any processing and exit. */ + goto unlock; + } + if (++batch_count == PTNET_RX_BATCH) { /* Some packets have been pushed to the network stack. * We need to update the CSB to tell the host about the new @@ -2048,10 +2056,8 @@ head, ring->tail)); taskqueue_enqueue(pq->taskq, &pq->task); } - +unlock: PTNET_Q_UNLOCK(pq); - - return 0; } static void From owner-svn-soc-all@freebsd.org Mon Jul 18 09:09:19 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 680BEB9C7BB for ; Mon, 18 Jul 2016 09:09:19 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4A70C1EA7 for ; Mon, 18 Jul 2016 09:09:19 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I99JFE051931 for ; Mon, 18 Jul 2016 09:09:19 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I99IkC051352 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:09:18 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:09:18 GMT Message-Id: <201607180909.u6I99IkC051352@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306420 - in soc2016/vincenzo/head/sys: dev/netmap modules/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:09:19 -0000 Author: vincenzo Date: Mon Jul 18 09:09:17 2016 New Revision: 306420 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306420 Log: freebsd: ptnet: add control path support for DEVICE_POLLING Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c soc2016/vincenzo/head/sys/modules/netmap/Makefile Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:05 2016 (r306419) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:17 2016 (r306420) @@ -199,6 +199,10 @@ static void ptnet_rx_eof(struct ptnet_queue *pq); static void ptnet_rx_task(void *context, int pending); +#ifdef DEVICE_POLLING +static poll_handler_t ptnet_poll; +#endif + static device_method_t ptnet_methods[] = { DEVMETHOD(device_probe, ptnet_probe), DEVMETHOD(device_attach, ptnet_attach), @@ -406,7 +410,10 @@ } ifp->if_capenable = ifp->if_capabilities; - +#ifdef DEVICE_POLLING + /* Don't enable polling by default. */ + ifp->if_capabilities |= IFCAP_POLLING; +#endif snprintf(sc->lock_name, sizeof(sc->lock_name), "%s", device_get_nameunit(dev)); mtx_init(&sc->lock, sc->lock_name, "ptnet core lock", MTX_DEF); @@ -467,6 +474,11 @@ struct ptnet_softc *sc = device_get_softc(dev); int i; +#ifdef DEVICE_POLLING + if (sc->ifp->if_capenable & IFCAP_POLLING) { + ether_poll_deregister(sc->ifp); + } +#endif if (sc->queues) { /* Drain taskqueues before calling if_detach. */ for (i = 0; i < sc->num_rings; i++) { @@ -713,7 +725,7 @@ struct ptnet_softc *sc = ifp->if_softc; device_t dev = sc->dev; struct ifreq *ifr = (struct ifreq *)data; - int err = 0; + int mask, err = 0; switch (cmd) { case SIOCSIFFLAGS: @@ -734,9 +746,45 @@ case SIOCSIFCAP: device_printf(dev, "SIOCSIFCAP %x %x\n", ifr->ifr_reqcap, ifp->if_capenable); - PTNET_CORE_LOCK(sc); + mask = ifr->ifr_reqcap ^ ifp->if_capenable; +#ifdef DEVICE_POLLING + if (mask & IFCAP_POLLING) { + struct ptnet_queue *pq; + int i; + + if (ifr->ifr_reqcap & IFCAP_POLLING) { + err = ether_poll_register(ptnet_poll, ifp); + if (err) { + break; + } + /* Stop queues and sync with taskqueues. */ + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + for (i = 0; i < sc->num_rings; i++) { + pq = sc-> queues + i; + /* Make sure the worker sees the + * IFF_DRV_RUNNING down. */ + PTNET_Q_LOCK(pq); + pq->ptring->guest_need_kick = 0; + PTNET_Q_UNLOCK(pq); + /* Wait for rescheduling to finish. */ + if (pq->taskq) { + taskqueue_drain(pq->taskq, + &pq->task); + } + } + ifp->if_drv_flags |= IFF_DRV_RUNNING; + } else { + err = ether_poll_deregister(ifp); + for (i = 0; i < sc->num_rings; i++) { + pq = sc-> queues + i; + PTNET_Q_LOCK(pq); + pq->ptring->guest_need_kick = 1; + PTNET_Q_UNLOCK(pq); + } + } + } +#endif /* DEVICE_POLLING */ ifp->if_capenable = ifr->ifr_reqcap; - PTNET_CORE_UNLOCK(sc); break; case SIOCSIFMTU: @@ -1045,16 +1093,6 @@ } } -#define csb_notification_enable_all(_x, _na, _t, _fld, _v) \ - do { \ - struct ptnet_queue *queues = (_x)->queues; \ - int i; \ - if (_t == NR_RX) queues = (_x)->rxqueues; \ - for (i=0; i_fld = _v; \ - } \ - } while (0) \ - static void ptnet_update_vnet_hdr(struct ptnet_softc *sc) { @@ -1070,6 +1108,7 @@ struct ifnet *ifp = na->ifp; struct ptnet_softc *sc = ifp->if_softc; int native = (na == &sc->ptna_nm->hwup.up); + struct ptnet_queue *pq; enum txrx t; int ret = 0; int i; @@ -1086,17 +1125,22 @@ * until these will be processed. */ if (native && !onoff && na->active_fds == 0) { D("Exit netmap mode, re-enable interrupts"); - csb_notification_enable_all(sc, na, NR_TX, guest_need_kick, 1); - csb_notification_enable_all(sc, na, NR_RX, guest_need_kick, 1); + for (i = 0; i < sc->num_rings; i++) { + pq = sc->queues + i; + pq->ptring->guest_need_kick = 1; + } } if (onoff) { if (sc->backend_regifs == 0) { /* Initialize notification enable fields in the CSB. */ - csb_notification_enable_all(sc, na, NR_TX, host_need_kick, 1); - csb_notification_enable_all(sc, na, NR_TX, guest_need_kick, 0); - csb_notification_enable_all(sc, na, NR_RX, host_need_kick, 1); - csb_notification_enable_all(sc, na, NR_RX, guest_need_kick, 1); + for (i = 0; i < sc->num_rings; i++) { + pq = sc->queues + i; + pq->ptring->host_need_kick = 1; + pq->ptring->guest_need_kick = + (!(ifp->if_capenable & IFCAP_POLLING) + && i >= sc->num_tx_rings); + } /* Set the virtio-net header length. */ ptnet_update_vnet_hdr(sc); @@ -2078,3 +2122,19 @@ ptnet_drain_transmit_queue(pq); } +#ifdef DEVICE_POLLING +static int +ptnet_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) +{ + struct ptnet_softc *sc = ifp->if_softc; + + /* We don't need to handle differently POLL_AND_CHECK_STATUS and + * POLL_ONLY, since we don't have an Interrupt Status Register. */ + + //rx_done = ptnet_rx_eof(pq) + // ptnet_drain_transmit_queue(pq); + (void)sc; + + return 0; //(rx_done); +} +#endif /* DEVICE_POLLING */ Modified: soc2016/vincenzo/head/sys/modules/netmap/Makefile ============================================================================== --- soc2016/vincenzo/head/sys/modules/netmap/Makefile Mon Jul 18 09:09:05 2016 (r306419) +++ soc2016/vincenzo/head/sys/modules/netmap/Makefile Mon Jul 18 09:09:17 2016 (r306420) @@ -8,7 +8,7 @@ .PATH: ${.CURDIR}/../../dev/netmap .PATH.h: ${.CURDIR}/../../net -CFLAGS += -I${.CURDIR}/../../ -D INET +CFLAGS += -I${.CURDIR}/../../ -D INET -D DEVICE_POLLING KMOD = netmap SRCS = device_if.h bus_if.h pci_if.h opt_netmap.h SRCS += netmap.c netmap.h netmap_kern.h From owner-svn-soc-all@freebsd.org Mon Jul 18 09:09:28 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F07EB9C7DC for ; Mon, 18 Jul 2016 09:09:28 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E47271EC4 for ; Mon, 18 Jul 2016 09:09:27 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I99RNS057256 for ; Mon, 18 Jul 2016 09:09:27 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I99Rpu056568 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:09:27 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:09:27 GMT Message-Id: <201607180909.u6I99Rpu056568@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306421 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:09:28 -0000 Author: vincenzo Date: Mon Jul 18 09:09:26 2016 New Revision: 306421 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306421 Log: freebsd: ptnet: implement polling function Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:17 2016 (r306420) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:26 2016 (r306421) @@ -170,7 +170,9 @@ static int ptnet_init_locked(struct ptnet_softc *sc); static int ptnet_stop(struct ptnet_softc *sc); static int ptnet_transmit(struct ifnet *ifp, struct mbuf *m); -static int ptnet_drain_transmit_queue(struct ptnet_queue *pq); +static int ptnet_drain_transmit_queue(struct ptnet_queue *pq, + unsigned int budget, + bool may_resched); static void ptnet_qflush(struct ifnet *ifp); static void ptnet_tx_task(void *context, int pending); @@ -196,7 +198,8 @@ static unsigned ptnet_rx_discard(struct netmap_kring *kring, unsigned int head); -static void ptnet_rx_eof(struct ptnet_queue *pq); +static int ptnet_rx_eof(struct ptnet_queue *pq, unsigned int budget, + bool may_resched); static void ptnet_rx_task(void *context, int pending); #ifdef DEVICE_POLLING @@ -241,6 +244,7 @@ #define PTNET_BUF_RING_SIZE 4096 #define PTNET_RX_BUDGET 512 #define PTNET_RX_BATCH 1 +#define PTNET_TX_BUDGET 512 #define PTNET_TX_BATCH 64 #define PTNET_HDR_SIZE sizeof(struct virtio_net_hdr_mrg_rxbuf) #define PTNET_MAX_PKT_SIZE 65536 @@ -1273,7 +1277,7 @@ /* Like vtnet, if_igb and if_em drivers when using MSI-X interrupts, * receive-side processing is executed directly in the interrupt * service routine. Alternatively, we may schedule the taskqueue. */ - ptnet_rx_eof(pq); + ptnet_rx_eof(pq, PTNET_RX_BUDGET, true); } /* The following offloadings-related functions are taken from the vtnet @@ -1637,7 +1641,8 @@ /* This function may be called by the network stack, or by * by the taskqueue thread. */ static int -ptnet_drain_transmit_queue(struct ptnet_queue *pq) +ptnet_drain_transmit_queue(struct ptnet_queue *pq, unsigned int budget, + bool may_resched) { struct ptnet_softc *sc = pq->sc; bool have_vnet_hdr = sc->vnet_hdr_len; @@ -1648,6 +1653,7 @@ struct netmap_kring *kring; struct netmap_ring *ring; struct netmap_slot *slot; + unsigned int count = 0; unsigned int minspace; unsigned int head; unsigned int lim; @@ -1659,7 +1665,9 @@ if (!PTNET_Q_TRYLOCK(pq)) { /* We failed to acquire the lock, schedule the taskqueue. */ RD(1, "Deferring TX work"); - taskqueue_enqueue(pq->taskq, &pq->task); + if (may_resched) { + taskqueue_enqueue(pq->taskq, &pq->task); + } return 0; } @@ -1677,7 +1685,7 @@ head = ring->head; minspace = sc->min_tx_space; - for (;;) { + while (count < budget) { if (PTNET_TX_NOSPACE(head, kring, minspace)) { /* We ran out of slot, let's see if the host has * freed up some, by reading hwcur and hwtail from @@ -1793,6 +1801,7 @@ m_freem(mhead); + count ++; if (++batch_count == PTNET_TX_BATCH) { ptnet_ring_update(pq, kring, head, NAF_FORCE_RECLAIM); batch_count = 0; @@ -1803,9 +1812,15 @@ ptnet_ring_update(pq, kring, head, NAF_FORCE_RECLAIM); } + if (count >= budget && may_resched) { + DBG(RD(1, "out of budget: resched, %d mbufs pending\n", + drbr_inuse(ifp, pq->bufring))); + taskqueue_enqueue(pq->taskq, &pq->task); + } + PTNET_Q_UNLOCK(pq); - return 0; + return count; } static int @@ -1845,7 +1860,9 @@ return err; } - return ptnet_drain_transmit_queue(pq); + err = ptnet_drain_transmit_queue(pq, PTNET_TX_BUDGET, true); + + return (err < 0) ? err : 0; } static unsigned int @@ -1903,8 +1920,8 @@ return mtail; } -static void -ptnet_rx_eof(struct ptnet_queue *pq) +static int +ptnet_rx_eof(struct ptnet_queue *pq, unsigned int budget, bool may_resched) { struct ptnet_softc *sc = pq->sc; bool have_vnet_hdr = sc->vnet_hdr_len; @@ -1913,10 +1930,10 @@ struct netmap_kring *kring = na->rx_rings + pq->kring_id; struct netmap_ring *ring = kring->ring; unsigned int const lim = kring->nkr_num_slots - 1; - unsigned int budget = PTNET_RX_BUDGET; unsigned int head = ring->head; unsigned int batch_count = 0; struct ifnet *ifp = sc->ifp; + unsigned int count = 0; PTNET_Q_LOCK(pq); @@ -1926,7 +1943,7 @@ kring->nr_kflags &= ~NKR_PENDINTR; - do { + while (count < budget) { unsigned int prev_head = head; struct mbuf *mhead, *mtail; struct virtio_net_hdr *vh; @@ -2014,8 +2031,10 @@ __func__, head, prev_head); head = prev_head; m_freem(mhead); - taskqueue_enqueue(pq->taskq, - &pq->task); + if (may_resched) { + taskqueue_enqueue(pq->taskq, + &pq->task); + } goto escape; } @@ -2079,6 +2098,7 @@ goto unlock; } + count ++; if (++batch_count == PTNET_RX_BATCH) { /* Some packets have been pushed to the network stack. * We need to update the CSB to tell the host about the new @@ -2086,14 +2106,14 @@ ptnet_ring_update(pq, kring, head, NAF_FORCE_READ); batch_count = 0; } - } while (--budget); + } escape: if (batch_count) { ptnet_ring_update(pq, kring, head, NAF_FORCE_READ); } - if (!budget) { + if (count >= budget && may_resched) { /* If we ran out of budget or the double-check found new * slots to process, schedule the taskqueue. */ DBG(RD(1, "out of budget: resched h %u t %u\n", @@ -2102,6 +2122,8 @@ } unlock: PTNET_Q_UNLOCK(pq); + + return count; } static void @@ -2110,7 +2132,7 @@ struct ptnet_queue *pq = context; DBG(RD(1, "%s: pq #%u\n", __func__, pq->kring_id)); - ptnet_rx_eof(pq); + ptnet_rx_eof(pq, PTNET_RX_BUDGET, true); } static void @@ -2119,22 +2141,65 @@ struct ptnet_queue *pq = context; DBG(RD(1, "%s: pq #%u\n", __func__, pq->kring_id)); - ptnet_drain_transmit_queue(pq); + ptnet_drain_transmit_queue(pq, PTNET_TX_BUDGET, true); } #ifdef DEVICE_POLLING +/* We don't need to handle differently POLL_AND_CHECK_STATUS and + * POLL_ONLY, since we don't have an Interrupt Status Register. */ static int -ptnet_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) +ptnet_poll(struct ifnet *ifp, enum poll_cmd cmd, int budget) { struct ptnet_softc *sc = ifp->if_softc; + unsigned int queue_budget; + unsigned int count = 0; + bool borrow = false; + int i; - /* We don't need to handle differently POLL_AND_CHECK_STATUS and - * POLL_ONLY, since we don't have an Interrupt Status Register. */ + KASSERT(sc->num_rings > 0, "Found no queues in while polling ptnet"); + queue_budget = MIN(budget / sc->num_rings, 1); + RD(1, "Per-queue budget is %d", queue_budget); + + while (budget) { + unsigned int rcnt = 0; + + for (i = 0; i < sc->num_rings; i++) { + struct ptnet_queue *pq = sc->queues + i; + + if (borrow) { + queue_budget = MIN(queue_budget, budget); + if (queue_budget == 0) { + break; + } + } + + if (i < sc->num_tx_rings) { + rcnt += ptnet_drain_transmit_queue(pq, + queue_budget, false); + } else { + rcnt += ptnet_rx_eof(pq, queue_budget, + false); + } + } + + if (!rcnt) { + /* A scan of the queues gave no result, we can + * stop here. */ + break; + } + + if (rcnt > budget) { + /* This may happen when initial budget < sc->num_rings, + * since one packet budget is given to each queue + * anyway. Just pretend we didn't eat "so much". */ + rcnt = budget; + } + count += rcnt; + budget -= rcnt; + borrow = true; + } - //rx_done = ptnet_rx_eof(pq) - // ptnet_drain_transmit_queue(pq); - (void)sc; - return 0; //(rx_done); + return count; } #endif /* DEVICE_POLLING */ From owner-svn-soc-all@freebsd.org Mon Jul 18 09:09:40 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D691DB9C818 for ; Mon, 18 Jul 2016 09:09:40 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CA1F31ED8 for ; Mon, 18 Jul 2016 09:09:40 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I99eXZ066818 for ; Mon, 18 Jul 2016 09:09:40 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I99eZ4066062 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:09:40 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:09:40 GMT Message-Id: <201607180909.u6I99eZ4066062@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306422 - soc2016/vincenzo/head/sys/modules/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:09:40 -0000 Author: vincenzo Date: Mon Jul 18 09:09:39 2016 New Revision: 306422 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306422 Log: ptnet: freebsd: temporarily remove -D DEVICE_POLLING flag Modified: soc2016/vincenzo/head/sys/modules/netmap/Makefile Modified: soc2016/vincenzo/head/sys/modules/netmap/Makefile ============================================================================== --- soc2016/vincenzo/head/sys/modules/netmap/Makefile Mon Jul 18 09:09:26 2016 (r306421) +++ soc2016/vincenzo/head/sys/modules/netmap/Makefile Mon Jul 18 09:09:39 2016 (r306422) @@ -8,7 +8,7 @@ .PATH: ${.CURDIR}/../../dev/netmap .PATH.h: ${.CURDIR}/../../net -CFLAGS += -I${.CURDIR}/../../ -D INET -D DEVICE_POLLING +CFLAGS += -I${.CURDIR}/../../ -D INET KMOD = netmap SRCS = device_if.h bus_if.h pci_if.h opt_netmap.h SRCS += netmap.c netmap.h netmap_kern.h From owner-svn-soc-all@freebsd.org Mon Jul 18 09:09:49 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 683FEB9C835 for ; Mon, 18 Jul 2016 09:09:49 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 41D471EEB for ; Mon, 18 Jul 2016 09:09:49 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I99nHK072604 for ; Mon, 18 Jul 2016 09:09:49 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I99mRh072099 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:09:48 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:09:48 GMT Message-Id: <201607180909.u6I99mRh072099@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306423 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:09:49 -0000 Author: vincenzo Date: Mon Jul 18 09:09:48 2016 New Revision: 306423 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306423 Log: freebsd: ptnet: add periodic timer to accumulate statistics Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:39 2016 (r306422) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:48 2016 (r306423) @@ -153,6 +153,8 @@ struct netmap_pt_guest_adapter ptna_dr; /* XXX we should move ptna_dr and backend_regifs inside struct * netmap_pt_guest_adapter and have just one instance of that. */ + + struct callout tick; }; #define PTNET_CORE_LOCK(_sc) mtx_lock(&(_sc)->lock) @@ -178,6 +180,7 @@ static int ptnet_media_change(struct ifnet *ifp); static void ptnet_media_status(struct ifnet *ifp, struct ifmediareq *ifmr); +static void ptnet_tick(void *opaque); static int ptnet_irqs_init(struct ptnet_softc *sc); static void ptnet_irqs_fini(struct ptnet_softc *sc); @@ -421,6 +424,7 @@ snprintf(sc->lock_name, sizeof(sc->lock_name), "%s", device_get_nameunit(dev)); mtx_init(&sc->lock, sc->lock_name, "ptnet core lock", MTX_DEF); + callout_init_mtx(&sc->tick, &sc->lock, 0); sc->backend_regifs = 0; @@ -483,6 +487,8 @@ ether_poll_deregister(sc->ifp); } #endif + callout_drain(&sc->tick); + if (sc->queues) { /* Drain taskqueues before calling if_detach. */ for (i = 0; i < sc->num_rings; i++) { @@ -887,6 +893,8 @@ device_printf(sc->dev, "%s: min_tx_space = %u\n", __func__, sc->min_tx_space); + callout_reset(&sc->tick, hz, ptnet_tick, sc); + ifp->if_drv_flags |= IFF_DRV_RUNNING; return 0; @@ -921,6 +929,7 @@ * so that after this loop we are sure nobody is working anymore with * the device. This scheme is taken from the vtnet driver. */ ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + callout_stop(&sc->tick); for (i = 0; i < sc->num_rings; i++) { PTNET_Q_LOCK(sc->queues + i); PTNET_Q_UNLOCK(sc->queues + i); @@ -973,6 +982,16 @@ return 0; } +/* Called under core lock. */ +static void +ptnet_tick(void *opaque) +{ + struct ptnet_softc *sc = opaque; + struct ifnet *ifp = sc->ifp; + + (void)ifp; + callout_schedule(&sc->tick, hz); +} static void ptnet_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) From owner-svn-soc-all@freebsd.org Mon Jul 18 09:09:58 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 638D7B9C857 for ; Mon, 18 Jul 2016 09:09:58 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 42DCB1EFF for ; Mon, 18 Jul 2016 09:09:58 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I99wqr077785 for ; Mon, 18 Jul 2016 09:09:58 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I99vr5077395 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:09:57 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:09:57 GMT Message-Id: <201607180909.u6I99vr5077395@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306424 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:09:58 -0000 Author: vincenzo Date: Mon Jul 18 09:09:57 2016 New Revision: 306424 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306424 Log: freebsd: ptnet: collect interface statistics Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:48 2016 (r306423) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:57 2016 (r306424) @@ -103,18 +103,27 @@ struct ptnet_softc; +struct ptnet_queue_stats { + uint64_t packets; /* if_[io]packets */ + uint64_t bytes; /* if_[io]bytes */ + uint64_t errors; /* if_[io]errors */ + uint64_t iqdrops; /* if_iqdrops */ + uint64_t mcasts; /* if_[io]mcasts */ +}; + struct ptnet_queue { - struct ptnet_softc *sc; - struct resource *irq; - void *cookie; - int kring_id; - struct ptnet_ring *ptring; - unsigned int kick; - struct mtx lock; - struct buf_ring *bufring; /* for TX queues */ - struct taskqueue *taskq; - struct task task; - char lock_name[16]; + struct ptnet_softc *sc; + struct resource *irq; + void *cookie; + int kring_id; + struct ptnet_ring *ptring; + unsigned int kick; + struct mtx lock; + struct buf_ring *bufring; /* for TX queues */ + struct ptnet_queue_stats stats; + struct taskqueue *taskq; + struct task task; + char lock_name[16]; }; #define PTNET_Q_LOCK(_pq) mtx_lock(&(_pq)->lock) @@ -988,8 +997,33 @@ { struct ptnet_softc *sc = opaque; struct ifnet *ifp = sc->ifp; + struct ptnet_queue_stats stats[2]; + int i; + + /* Accumulate statistics over the queues. */ + memset(stats, 0, sizeof(stats)); + for (i = 0; i < sc->num_rings; i++) { + struct ptnet_queue *pq = sc->queues + i; + int idx = (i < sc->num_tx_rings) ? 0 : 1; + + stats[idx].packets += pq->stats.packets; + stats[idx].bytes += pq->stats.bytes; + stats[idx].errors += pq->stats.errors; + stats[idx].iqdrops += pq->stats.iqdrops; + stats[idx].mcasts += pq->stats.mcasts; + } + + /* Update interface statistics. */ + ifp->if_opackets = stats[0].packets; + ifp->if_obytes = stats[0].bytes; + ifp->if_omcasts = stats[0].mcasts; + ifp->if_oerrors = stats[0].errors; + ifp->if_ipackets = stats[1].packets; + ifp->if_ibytes = stats[1].bytes; + ifp->if_imcasts = stats[1].mcasts; + ifp->if_ierrors = stats[1].errors; + ifp->if_iqdrops = stats[1].iqdrops; - (void)ifp; callout_schedule(&sc->tick, hz); } @@ -1759,6 +1793,7 @@ * occurred while preparing the vnet * header. Let's go ahead with the next * packet. */ + pq->stats.errors ++; drbr_advance(ifp, pq->bufring); continue; } @@ -1818,6 +1853,12 @@ /* Copy the packet to listeners. */ ETHER_BPF_MTAP(ifp, mhead); + pq->stats.packets ++; + pq->stats.bytes += mhead->m_pkthdr.len; + if (mhead->m_flags & M_MCAST) { + pq->stats.mcasts ++; + } + m_freem(mhead); count ++; @@ -1876,6 +1917,7 @@ /* ENOBUFS when the bufring is full */ RD(1, "%s: drbr_enqueue() failed %d\n", __func__, err); + pq->stats.errors ++; return err; } @@ -1969,7 +2011,7 @@ struct netmap_slot *slot; unsigned int nmbuf_len; uint8_t *nmbuf; - +host_sync: if (head == ring->tail) { /* We ran out of slot, let's see if the host has * added some, by reading hwcur and hwtail from @@ -2004,8 +2046,10 @@ /* There is no good reason why host should * put the header in multiple netmap slots. * If this is the case, discard. */ + RD(1, "Fragmented vnet-hdr: dropping"); head = ptnet_rx_discard(kring, head); - continue; + pq->stats.iqdrops ++; + goto skip; } ND(1, "%s: vnet hdr: flags %x csum_start %u " "csum_ofs %u hdr_len = %u gso_size %u " @@ -2024,6 +2068,7 @@ if (unlikely(mhead == NULL)) { device_printf(sc->dev, "%s: failed to allocate mbuf " "head\n", __func__); + pq->stats.errors ++; break; } @@ -2050,6 +2095,7 @@ __func__, head, prev_head); head = prev_head; m_freem(mhead); + pq->stats.errors ++; if (may_resched) { taskqueue_enqueue(pq->taskq, &pq->task); @@ -2067,11 +2113,12 @@ if (unlikely(head == ring->tail)) { /* The very last slot prepared by the host has - * the NS_MOREFRAG set. This is an error that - * we handle by accepting the truncated packet, - * and let the network stack drop it. */ - RD(1, "Warning: Truncating incomplete packet"); - break; + * the NS_MOREFRAG set. Drop it and continue + * the outer cycle (to do the double-check). */ + RD(1, "Incomplete packet: dropping"); + m_freem(mhead); + pq->stats.iqdrops ++; + goto host_sync; } slot = ring->slot + head; @@ -2104,9 +2151,17 @@ if (have_vnet_hdr && (vh->flags & (VIRTIO_NET_HDR_F_NEEDS_CSUM | VIRTIO_NET_HDR_F_DATA_VALID))) { - ptnet_rx_csum(mhead, vh); + if (unlikely(ptnet_rx_csum(mhead, vh))) { + m_freem(mhead); + RD(1, "Csum offload error: dropping"); + pq->stats.iqdrops ++; + goto skip; + } } + pq->stats.packets ++; + pq->stats.bytes += mhead->m_pkthdr.len; + PTNET_Q_UNLOCK(pq); (*ifp->if_input)(ifp, mhead); PTNET_Q_LOCK(pq); @@ -2116,7 +2171,7 @@ * have the lock. Stop any processing and exit. */ goto unlock; } - +skip: count ++; if (++batch_count == PTNET_RX_BATCH) { /* Some packets have been pushed to the network stack. From owner-svn-soc-all@freebsd.org Mon Jul 18 09:11:13 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A18FAB9C937 for ; Mon, 18 Jul 2016 09:11:13 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 923A51F9D for ; Mon, 18 Jul 2016 09:11:13 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I9BDYP028574 for ; Mon, 18 Jul 2016 09:11:13 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I9BCRY027913 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:11:12 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:11:12 GMT Message-Id: <201607180911.u6I9BCRY027913@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306425 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:11:13 -0000 Author: vincenzo Date: Mon Jul 18 09:11:12 2016 New Revision: 306425 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306425 Log: freebsd: ptnet_transmit: don't drain queue in POLLING mode Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:09:57 2016 (r306424) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:11:12 2016 (r306425) @@ -1921,6 +1921,12 @@ return err; } + if (ifp->if_capenable & IFCAP_POLLING) { + /* If polling is on, the transmit queues will be + * drained by the poller. */ + return 0; + } + err = ptnet_drain_transmit_queue(pq, PTNET_TX_BUDGET, true); return (err < 0) ? err : 0; From owner-svn-soc-all@freebsd.org Mon Jul 18 09:11:22 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4FE47B9C94A for ; Mon, 18 Jul 2016 09:11:22 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 439971014 for ; Mon, 18 Jul 2016 09:11:22 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I9BMro035278 for ; Mon, 18 Jul 2016 09:11:22 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I9BLYT034021 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:11:21 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:11:21 GMT Message-Id: <201607180911.u6I9BLYT034021@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306426 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:11:22 -0000 Author: vincenzo Date: Mon Jul 18 09:11:21 2016 New Revision: 306426 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306426 Log: freebsd: ptnet_poll: fix queue budget computation Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:11:12 2016 (r306425) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:11:21 2016 (r306426) @@ -2237,7 +2237,7 @@ int i; KASSERT(sc->num_rings > 0, "Found no queues in while polling ptnet"); - queue_budget = MIN(budget / sc->num_rings, 1); + queue_budget = MAX(budget / sc->num_rings, 1); RD(1, "Per-queue budget is %d", queue_budget); while (budget) { From owner-svn-soc-all@freebsd.org Mon Jul 18 09:12:26 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6A55B9C969 for ; Mon, 18 Jul 2016 09:12:26 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A9E1312B9 for ; Mon, 18 Jul 2016 09:12:26 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I9CQnI058280 for ; Mon, 18 Jul 2016 09:12:26 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I9CQ1h058272 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:12:26 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:12:26 GMT Message-Id: <201607180912.u6I9CQ1h058272@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306427 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:12:26 -0000 Author: vincenzo Date: Mon Jul 18 09:12:25 2016 New Revision: 306427 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306427 Log: freebsd: ptnet: don't use deprecated CTRL register Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:11:21 2016 (r306426) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 18 09:12:25 2016 (r306427) @@ -679,10 +679,6 @@ cpu_cur = CPU_NEXT(cpu_cur); } - /* Tell the hypervisor that we have allocated the MSI-X vectors, - * so that it can do its own setup. */ - bus_write_4(sc->iomem, PTNET_IO_CTRL, PTNET_CTRL_IRQINIT); - return 0; err_path: ptnet_irqs_fini(sc); @@ -695,10 +691,6 @@ device_t dev = sc->dev; int i; - /* Tell the hypervisor that we are going to deallocate the - * MSI-X vectors, so that it can do its own cleanup. */ - bus_write_4(sc->iomem, PTNET_IO_CTRL, PTNET_CTRL_IRQFINI); - for (i = 0; i < sc->num_rings; i++) { struct ptnet_queue *pq = sc->queues + i; From owner-svn-soc-all@freebsd.org Mon Jul 18 09:12:36 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15B3CB9C97C for ; Mon, 18 Jul 2016 09:12:36 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0920712DB for ; Mon, 18 Jul 2016 09:12:36 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I9CZIW063008 for ; Mon, 18 Jul 2016 09:12:35 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I9CZHj062398 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:12:35 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:12:35 GMT Message-Id: <201607180912.u6I9CZHj062398@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306428 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:12:36 -0000 Author: vincenzo Date: Mon Jul 18 09:12:34 2016 New Revision: 306428 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306428 Log: netmap_virt: ptnet: remove obsolete CTRL register Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h Mon Jul 18 09:12:25 2016 (r306427) +++ soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h Mon Jul 18 09:12:34 2016 (r306428) @@ -220,7 +220,7 @@ #define PTNET_IO_PTFEAT 0 #define PTNET_IO_PTCTL 4 #define PTNET_IO_PTSTS 8 -#define PTNET_IO_CTRL 12 +/* hole */ #define PTNET_IO_MAC_LO 16 #define PTNET_IO_MAC_HI 20 #define PTNET_IO_CSBBAH 24 @@ -238,14 +238,6 @@ /* If defined, CSB is allocated by the guest, not by the host. */ #define PTNET_CSB_ALLOC -/* Tell the hypervisor that guest has allocated the MSI-X - * interrupts, so that it can setup the host --> guest - * notification system (e.g. irqfd). */ -#define PTNET_CTRL_IRQINIT 1 -/* Tell the hypervisor to tear down the host --> guest - * notification system, since guest has deallocated the MSI-X. */ -#define PTNET_CTRL_IRQFINI 2 - /* CSB for the ptnet device. */ struct ptnet_csb { struct ptnet_ring rings[NET_PARAVIRT_CSB_SIZE/sizeof(struct ptnet_ring)]; From owner-svn-soc-all@freebsd.org Mon Jul 18 09:12:48 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C7F1CB9C9B9 for ; Mon, 18 Jul 2016 09:12:48 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BBA7312F4 for ; Mon, 18 Jul 2016 09:12:48 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u6I9CmE8071495 for ; Mon, 18 Jul 2016 09:12:48 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u6I9CmE6071043 for svn-soc-all@FreeBSD.org; Mon, 18 Jul 2016 09:12:48 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 18 Jul 2016 09:12:48 GMT Message-Id: <201607180912.u6I9CmE6071043@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r306429 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 09:12:48 -0000 Author: vincenzo Date: Mon Jul 18 09:12:47 2016 New Revision: 306429 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=306429 Log: netmap_mem: netmap_initialized only used in FreeBSD Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_mem2.c Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_mem2.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/netmap_mem2.c Mon Jul 18 09:12:34 2016 (r306428) +++ soc2016/vincenzo/head/sys/dev/netmap/netmap_mem2.c Mon Jul 18 09:12:47 2016 (r306429) @@ -562,15 +562,19 @@ return ret; } +#if defined(__FreeBSD__) extern int netmap_initialized; +#endif static void nm_mem_release_id(struct netmap_mem_d *nmd) { +#if defined(__FreeBSD__) if (!netmap_initialized) { D("skip, nm_mem could be gone"); return; } +#endif NMA_LOCK(&nm_mem); nmd->prev->next = nmd->next;