From owner-svn-soc-all@freebsd.org Thu May 26 15:34: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 25ABAB4B6E7 for ; Thu, 26 May 2016 15:34: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 00A5C1946 for ; Thu, 26 May 2016 15:34: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 u4QFYo6D023233 for ; Thu, 26 May 2016 15:34:50 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4QFYoNi023217 for svn-soc-all@FreeBSD.org; Thu, 26 May 2016 15:34:50 GMT (envelope-from vincenzo@FreeBSD.org) Date: Thu, 26 May 2016 15:34:50 GMT Message-Id: <201605261534.u4QFYoNi023217@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: r303934 - 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:34:51 -0000 Author: vincenzo Date: Thu May 26 15:34:49 2016 New Revision: 303934 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303934 Log: ptnet: allocate CSB 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:34:25 2016 (r303933) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Thu May 26 15:34:49 2016 (r303934) @@ -96,12 +96,14 @@ char core_mtx_name[16]; char hwaddr[ETHER_ADDR_LEN]; + /* Mirror of PTFEAT register. */ + uint32_t ptfeatures; + /* PCI BARs support. */ struct resource *iomem; struct resource *msix_mem; - /* Mirror of PTFEAT register. */ - uint32_t ptfeatures; + struct ptnet_csb *csb; }; #define PTNET_CORE_LOCK_INIT(_sc) do { \ @@ -169,6 +171,9 @@ ptnet_attach(device_t dev) { uint32_t ptfeatures = NET_PTN_FEATURES_BASE; +#if 0 + unsigned int num_rx_rings, num_tx_rings; +#endif struct ptnet_softc *sc; struct ifnet *ifp; int err, rid; @@ -184,8 +189,8 @@ 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"); + if (sc->iomem == NULL) { + device_printf(dev, "Failed to map I/O BAR\n"); return (ENXIO); } @@ -195,11 +200,21 @@ ptfeatures = bus_read_4(sc->iomem, PTNET_IO_PTFEAT); /* acked */ if (!(ptfeatures & NET_PTN_FEATURES_BASE)) { device_printf(dev, "Hypervisor does not support netmap " - "passthorugh"); + "passthorugh\n"); err = ENXIO; goto err_path; } sc->ptfeatures = ptfeatures; +#if 0 + num_tx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_TX_RINGS); + num_rx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_RX_RINGS); +#endif + sc->csb = malloc(sizeof(struct ptnet_csb), M_DEVBUF, M_NOWAIT | M_ZERO); + if (sc->csb == NULL) { + device_printf(dev, "Failed to allocate CSB\n"); + err = ENOMEM; + goto err_path; + } /* Setup Ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); @@ -256,6 +271,11 @@ sc->ifp = NULL; } + if (sc->csb) { + free(sc->csb, M_DEVBUF); + sc->csb = NULL; + } + PTNET_CORE_LOCK_FINI(sc); if (sc->iomem) {