From owner-svn-soc-all@freebsd.org Thu May 26 15:33:56 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 783CAB4B69A for ; Thu, 26 May 2016 15:33:56 +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 5284A18C9 for ; Thu, 26 May 2016 15:33:56 +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 u4QFXu3u021643 for ; Thu, 26 May 2016 15:33:56 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4QFXtwE021636 for svn-soc-all@FreeBSD.org; Thu, 26 May 2016 15:33:55 GMT (envelope-from vincenzo@FreeBSD.org) Date: Thu, 26 May 2016 15:33:55 GMT Message-Id: <201605261533.u4QFXtwE021636@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: r303932 - 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: Thu, 26 May 2016 15:33:56 -0000 Author: vincenzo Date: Thu May 26 15:33:55 2016 New Revision: 303932 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303932 Log: ptnet: alloc I/O PCI bar 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 Thu May 26 15:33:31 2016 (r303931) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Thu May 26 15:33:55 2016 (r303932) @@ -84,6 +84,10 @@ #include #include +#ifndef PTNET_CSB_ALLOC +#error "No support for on-device CSB" +#endif + struct ptnet_softc { device_t dev; struct ifnet *ifp; @@ -91,6 +95,8 @@ struct mtx core_mtx; char core_mtx_name[16]; char hwaddr[ETHER_ADDR_LEN]; + struct resource *iomem; + struct resource *msix_mem; }; #define PTNET_CORE_LOCK_INIT(_sc) do { \ @@ -142,7 +148,7 @@ static int ptnet_probe(device_t dev) { - printf("%s\n", __func__); + device_printf(dev, "%s\n", __func__); if (pci_get_vendor(dev) != PTNETMAP_PCI_VENDOR_ID || pci_get_device(dev) != PTNETMAP_PCI_NETIF_ID) { @@ -159,14 +165,25 @@ { struct ptnet_softc *sc; struct ifnet *ifp; + int rid; - printf("%s\n", __func__); + device_printf(dev, "%s\n", __func__); sc = device_get_softc(dev); sc->dev = dev; - PTNET_CORE_LOCK_INIT(sc); + /* Setup PCI resources. */ + pci_enable_busmaster(dev); + + rid = PCIR_BAR(PTNETMAP_IO_PCI_BAR); + sc->iomem = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, + RF_ACTIVE); + if (!sc->iomem) { + device_printf(dev, "Failed to map I/O BAR"); + return (ENXIO); + } + /* Setup Ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { device_printf(dev, "Failed to allocate ifnet\n"); @@ -197,6 +214,8 @@ ifp->if_capenable = ifp->if_capabilities; + PTNET_CORE_LOCK_INIT(sc); + return (0); } @@ -220,6 +239,9 @@ PTNET_CORE_LOCK_FINI(sc); + bus_release_resource(dev, SYS_RES_IOPORT, + PCIR_BAR(PTNETMAP_IO_PCI_BAR), sc->iomem); + return (0); }