Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 May 2016 15:34:50 GMT
From:      vincenzo@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r303934 - soc2016/vincenzo/head/sys/dev/netmap
Message-ID:  <201605261534.u4QFYoNi023217@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605261534.u4QFYoNi023217>