From owner-svn-soc-all@freebsd.org Sat Aug 20 14:58:12 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 542B2BC0F2C for ; Sat, 20 Aug 2016 14:58:12 +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 3A0FA1CA9 for ; Sat, 20 Aug 2016 14:58:12 +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 u7KEwCfU077715 for ; Sat, 20 Aug 2016 14:58:12 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u7KEwBsq077696 for svn-soc-all@FreeBSD.org; Sat, 20 Aug 2016 14:58:11 GMT (envelope-from vincenzo@FreeBSD.org) Date: Sat, 20 Aug 2016 14:58:11 GMT Message-Id: <201608201458.u7KEwBsq077696@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: r308089 - soc2016/vincenzo 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: Sat, 20 Aug 2016 14:58:12 -0000 Author: vincenzo Date: Sat Aug 20 14:58:10 2016 New Revision: 308089 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=308089 Log: more README update Modified: soc2016/vincenzo/README Modified: soc2016/vincenzo/README ============================================================================== --- soc2016/vincenzo/README Sat Aug 20 13:29:58 2016 (r308088) +++ soc2016/vincenzo/README Sat Aug 20 14:58:10 2016 (r308089) @@ -177,42 +177,94 @@ ========================== Final submission ================================= Final code of my project is available at the following SVN repository: - - https://svnweb.freebsd.org/socsvn/soc2016/vincenzo/ - + https://svnweb.freebsd.org/socsvn/soc2016/vincenzo/head/ which refers to FreeBSD head (11.0-CURRENT). -Moreover, all modifications I did to netmap (see below) have also been -merged also in the netmap GIT repository, so that can be also found at +The complete list of my SVN commits can be obtained with the following command +on the SVN repository + $ svn log -r 302612:HEAD +Instructions to extract patches of the subsystem I modified are reported +below. + +Moreover, all the modifications I did to netmap (see below) have also been +merged in the netmap GIT repository, and can be also found at https://github.com/luigirizzo/netmap. My code modifications belong to two different subsystems: - (1) netmap, where I added the ptnet device driver, implemented as a single + * netmap, where I added the ptnet device driver, implemented as a single source file, named head/sys/dev/netmap/if_ptnet.c. The file is available at the following link into the SVN repository: https://svnweb.freebsd.org/socsvn/soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c?view=markup - Moreover, some code reorganization and bug-fixing to other parts of + Moreover, some code reorganization and bug-fixes to other parts of netmap were necessary, including rearrangements of the ptnet driver for Linux that I had already developed. A complete patch (which also includes the if_ptnet.c FreeBSD driver) can be obtained with - the following command on the github netmap repository: + the following command on the netmap GIT repository: git diff --author="Vincenzo Maffione" 09936864fa5b67b82ef4a9907819b7018e9a38f2 master - (2) bhyve, where I reworked and fixed the netmap support and added the - emulation of the ptnet device. Code modifications can be obtained - with the following SVN diff on the SVN repository: - + * bhyve, where I reworked and fixed the netmap support and added the + emulation of the ptnet device. A patch containing my code + modifications can be obtained with the following command on the SVN + repository: $ svn diff -r 302612 usr.sbin/bhyve A modified version of QEMU that supports ptnet (not developed in the context of this GSOC project) is available here: - https://github.com/vmaffione/qemu/tree/ptnet - + +Short report of the work done during the project: + + * As a first step, I implemented the ptnet driver for FreeBSD, using + as a reference the driver that I had already developed on linux + (https://github.com/luigirizzo/netmap/blob/master/LINUX/ptnet/ptnet.c). + + I implemented the routines required to attach/detach the ptnet PCI + device (ptnet_probe, ptnet_attach, ptnet_detach, ...). + I developed the routines necessary to open and use the ptnet NIC in + netmap mode (ptnet_nm_register, ptnet_nm_txsync, ptnet_nm_rxsync, + ptnet_nm_config, ...). I managed to share some routines + (ptnet_nm_krings_create, ptnet_nm_krings_delete, ptnet_nm_dtor) between + the Linux and FreeBSD drivers, to improve code reuse. + + To allow the ptnet driver to be used by the network stack (and so by + socket applications), the FreeBSD network driver callbacks have been + implemented (ptnet_init, ptnet_ioctl, ptnet_transmit, ptnet_qflush, ...). + I also implemented a ptnet_poll() routine to support FreeBSD polling + (DEVICE_POLLING). + + * As a second step, I extended bhyve to emulate the ptnet device, + using as a reference the emulation that I had already developed for QEMU: + (https://github.com/vmaffione/qemu/blob/ptnet/hw/net/ptnetmap-netif.c). + I reused previous work from by myself, my mentor Luigi Rizzo + and Stefano Garzarella, that we did in the past to add netmap and + ptnetmap support for bhyve, and to extend libvmm and the vmm module to + +Example on how to use various NICs (including ptnet) with bhyve VMs: + + # bhyve ‐A ‐H ‐P ‐m 1G \ + ‐s 0,hostbridge \ + ‐s 1,lpc \ + ‐s 2:1,virtio‐net,tap1 \ /* virtio-net NIC + TAP backend */ + ‐s 2:2,virtio‐net,vale0:1 \ /* virtio-net NIC + netmap userspace backend */ + ‐s 2:3,ptnetmap‐memdev \ /* ptnetmap memory device, needed by the ptnet NIC */ + ‐s 2:4,ptnet,vale1:1 \ /* ptnet NIC + ptnetmap kernelspace backend */ + ‐l com1,stdio \ + vm1 + +where the bhyve VM named "vm1" has three virtual NICs: + * A virtio-net NIC which uses a traditional TAP device as a backend. + The TAP backend is implemented in userspace, as a part of bhyve. + * A virtio-net NIC which uses an host netmap VALE port as backend. The + netmap backend is implemented in userspace, as part of bhyve. + * A ptnet NIC which does the passthough of an host VALE port inside + the guest. The ptnetmap backend runs in a kernel thread, and it is + implemented as part of the netmap subsystem. + + ======================= Useful links ==============================