Date: Mon, 23 May 2016 13:33:36 GMT From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r303683 - in soc2016/vincenzo/head/sys: dev/netmap modules/netmap Message-ID: <201605231333.u4NDXaxR034227@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: vincenzo Date: Mon May 23 13:33:35 2016 New Revision: 303683 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303683 Log: Add driver stub for ptnet driver, as a new file Also add the new file to the netmap Makefile. Added: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h soc2016/vincenzo/head/sys/modules/netmap/Makefile Added: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon May 23 13:33:35 2016 (r303683) @@ -0,0 +1,185 @@ +/*- + * Copyright (c) 2016, Vincenzo Maffione <v.maffione@gmail.com> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Driver for ptnet paravirtualized network device. */ + +#include <sys/cdefs.h> +//__FBSDID("$FreeBSD: releng/10.2/sys/dev/netmap/netmap_ptnet.c xxx $"); + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/sockio.h> +#include <sys/mbuf.h> +#include <sys/malloc.h> +#include <sys/module.h> +#include <sys/socket.h> +#include <sys/sysctl.h> +#include <sys/random.h> +#include <sys/sglist.h> +#include <sys/lock.h> +#include <sys/mutex.h> +#include <sys/taskqueue.h> +#include <sys/smp.h> +#include <machine/smp.h> + +#include <vm/uma.h> + +#include <net/ethernet.h> +#include <net/if.h> +#include <net/if_arp.h> +#include <net/if_dl.h> +#include <net/if_types.h> +#include <net/if_media.h> +#include <net/if_vlan_var.h> + +#include <net/bpf.h> + +#include <netinet/in_systm.h> +#include <netinet/in.h> +#include <netinet/ip.h> +#include <netinet/ip6.h> +#include <netinet6/ip6_var.h> +#include <netinet/udp.h> +#include <netinet/tcp.h> +#include <netinet/sctp.h> + +#include <machine/bus.h> +#include <machine/resource.h> +#include <sys/bus.h> +#include <sys/rman.h> + +#include <dev/pci/pcivar.h> +#include <dev/pci/pcireg.h> + +#include "opt_inet.h" +#include "opt_inet6.h" + +#include <sys/selinfo.h> +#include <net/netmap.h> +#include <dev/netmap/netmap_kern.h> +#include <dev/netmap/netmap_virt.h> +#include <dev/netmap/netmap_mem2.h> + +struct ptnet_softc { + struct ifnet *ifp; +}; + +static int ptnet_probe(device_t); +static int ptnet_attach(device_t); +static int ptnet_detach(device_t); +static int ptnet_suspend(device_t); +static int ptnet_resume(device_t); +static int ptnet_shutdown(device_t); + +static device_method_t ptnet_methods[] = { + DEVMETHOD(device_probe, ptnet_probe), + DEVMETHOD(device_attach, ptnet_attach), + DEVMETHOD(device_detach, ptnet_detach), + DEVMETHOD(device_suspend, ptnet_suspend), + DEVMETHOD(device_resume, ptnet_resume), + DEVMETHOD(device_shutdown, ptnet_shutdown), + DEVMETHOD_END +}; + +static driver_t ptnet_driver = { + "ptnet", + ptnet_methods, + sizeof(struct ptnet_softc) +}; +static devclass_t ptnet_devclass; + +DRIVER_MODULE(ptnet, pci, ptnet_driver, ptnet_devclass, 0, 0); +MODULE_VERSION(ptnet, 1); +MODULE_DEPEND(ptnet, netmap, 1, 1, 1); + +static int +ptnet_probe(device_t dev) +{ + printf("%s\n", __func__); + + if (pci_get_vendor(dev) != PTNETMAP_PCI_VENDOR_ID || + pci_get_device(dev) != PTNETMAP_PCI_NETIF_ID) { + return (ENXIO); + } + + device_set_desc(dev, "ptnet network adapter"); + + return (BUS_PROBE_DEFAULT); +} + +static int +ptnet_attach(device_t dev) +{ + struct ptnet_softc *sc; + + printf("%s\n", __func__); + + sc = device_get_softc(dev); + sc->ifp = NULL; + + return (0); +} + +static int +ptnet_detach(device_t dev) +{ + printf("%s\n", __func__); + + return (0); +} + +static int +ptnet_suspend(device_t dev) +{ + struct ptnet_softc *sc; + + sc = device_get_softc(dev); + (void)sc; + + return (0); +} + +static int +ptnet_resume(device_t dev) +{ + struct ptnet_softc *sc; + + sc = device_get_softc(dev); + (void)sc; + + return (0); +} + +static int +ptnet_shutdown(device_t dev) +{ + /* + * Suspend already does all of what we need to + * do here; we just never expect to be resumed. + */ + return (ptnet_suspend(dev)); +} Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h Mon May 23 12:58:24 2016 (r303682) +++ soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h Mon May 23 13:33:35 2016 (r303683) @@ -252,7 +252,6 @@ #endif /* NETMAP_VIRT_CSB */ - #if defined(NETMAP_API) && !defined(NETMAP_VIRT_PTNETMAP) #define NETMAP_VIRT_PTNETMAP Modified: soc2016/vincenzo/head/sys/modules/netmap/Makefile ============================================================================== --- soc2016/vincenzo/head/sys/modules/netmap/Makefile Mon May 23 12:58:24 2016 (r303682) +++ soc2016/vincenzo/head/sys/modules/netmap/Makefile Mon May 23 13:33:35 2016 (r303683) @@ -21,6 +21,7 @@ SRCS += netmap_pipe.c SRCS += netmap_monitor.c SRCS += ptnetmap.c +SRCS += if_ptnet.c SRCS += opt_inet.h opt_inet6.h .include <bsd.kmod.mk>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605231333.u4NDXaxR034227>